Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Open file with default Windows application


Public 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 Const SW_ShowNormal = 1

'set the variable temp to the file type you want to open
'the OS will open that file with the application set to handle the extension of that file
Dim iReturn As Long , temp As String
temp = "myfile.doc"
iReturn = ShellExecute(frmMain.hwnd, "Open" , temp, vbNullString, App.Path, SW_ShowNormal)