
Launching an application from Outlook VB scripts
don't now anything about vb script, but in
VBA I'd use the shellexecute API
functions to launch the associated program. Just need to supply the
filename.
this is from total Vb Sourcebook
' Public property enumerated constants
Public Enum EnumShellExecuteErrors
seeNoError = -1 'Any value above 32
seeOUT_OF_MEMORY = 0 'The operating system is out of memory or
resources.
seeERROR_FILE_NOT_FOUND = 2 'The specified file was not found.
seeERROR_PATH_NOT_FOUND = 3 'The specified path was not found.
seeERROR_BAD_FORMAT = 11 'The .exe file is invalid (non-Win32? .exe
or error in .exe image).
seeSE_ERR_ACCESSDENIED = 5 'The operating system denied access to the
specified file.
seeSE_ERR_ASSOCINCOMPLETE = 27 'The file name association is incomplete
or invalid.
seeSE_ERR_DDEBUSY = 30 'The DDE transaction could not be
completed because other DDE transactions were being processed.
seeSE_ERR_DDEFAIL = 29 'The DDE transaction failed.
seeSE_ERR_DDETIMEOUT = 28 'The DDE transaction could not be
completed because the request timed out.
seeSE_ERR_DLLNOTFOUND = 32 'The specified dynamic-link library was
not found.
seeSE_ERR_NOASSOC = 31 'There is no application associated with
the given file name extension.
seeSE_ERR_OOM = 8 'There was not enough memory to complete
the operation.
seeSE_ERR_SHARE = 26 'A sharing violation occurred.
End Enum
Private Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
Public Function PrintDocument( lnghWnd As Long, strDocument As String)
As EnumShellExecuteErrors
' Comments : Prints a document by launching the program
' that is associated with the document (similar
' to what happens when you drag a document to the
' printer icon on the desktop.)
' Parameters: lnghWnd - Handle to window of a form
' strDocument - Path to the document to print
' Returns : -1 on Success, or one of the values in the
' EnumShellExecuteErrors constants on failure
Dim lngResult As Long
On Error GoTo PROC_ERR
mlnghInstance = 0
mlnghProcess = 0
lngResult = ShellExecute( _
lnghWnd, _
"print", _
strDocument, _
vbNullString, _
vbNullString, _
0)
If lngResult > 32 Then
PrintDocument = seeNoError
Else
PrintDocument = lngResult
End If
PROC_EXIT:
Exit Function
PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"PrintDocument"
Resume PROC_EXIT
End Function