Launching an application from Outlook VB scripts 
Author Message
 Launching an application from Outlook VB scripts

Hi

I am writting an application, that would send a form with attachment
to the Outlook user. When an user click an button on that form, it
will launch the appropriate application for that attachment based on
the extension. For example, I attach the fax (with it is tiff file)
and user can open it like they double click on the attachment.

I have looked around in this forum but haven't found any solution.

Does anyone have an idea how to do that from VB script ?

Thanks in advance

Quang



Tue, 04 May 2004 12:10:23 GMT  
 Launching an application from Outlook VB scripts
Hi

I am writting an application, that would send a form with attachment
to the Outlook user. When an user click an button on that form, it
will launch the appropriate application for that attachment based on
the extension. For example, I attach the fax (with it is tiff file)
and user can open it like they double click on the attachment.

I have looked around in this forum but haven't found any solution.

Does anyone have an idea how to do that from VB script ?

Thanks in advance

Quang



Wed, 05 May 2004 11:32:10 GMT  
 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



Fri, 07 May 2004 03:57:53 GMT  
 Launching an application from Outlook VB scripts
Hi

Thanks a lot for your reply.

I can't implement the code you suggest since I can't call API function
from VB script.

Regards

Quang


Quote:
> 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



Fri, 07 May 2004 13:05:01 GMT  
 Launching an application from Outlook VB scripts
Hi all

After 3 days hard working on this VBSctips, I found the simple
solution for the problem with VB scripts

Quote:
>>set app = CreateObject ("WScript.Shell")
>> app.run (filename)    

where filename is a fullpath to the file you want to lauch. It will
get appropriate applicatoion according to the extension name. I guest:
the run function will invoke the ShellExcute as suggested by the
previous reply.

Thanks

Quang



Fri, 07 May 2004 13:45:56 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Launching an application from Outlook VB scripts- repost

2. Launching Application from a Client-side Script

3. Launching Windows 95 applications from your VB application

4. Launch Application from Outlook

5. Outlook Script/VB Script

6. Launching 6 .vbs scripts simultaneously from a single script

7. Add-in causes Outlook crash when Outlook launches as a result of email hyperlink

8. Launching ASP scripts from VB.NET

9. Newbie: how to launch Outlook Express instead of Outlook

10. Launching an ASP script from VB.NET

11. VB script to display msg then launch executable

12. Making Outlook visible when launched from VB

 

 
Powered by phpBB® Forum Software