I would like to click on a file in a file list and have the associated application start. I cannot seem to find any documentation on this very common Windows capability.
Printable View
I would like to click on a file in a file list and have the associated application start. I cannot seem to find any documentation on this very common Windows capability.
'open a file with it's associated application
'this example opens addin.txt with notepad
'put this in a bas module
'
Public Declare Function ShellEx Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As Any, _
ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
'
Sub ShellDef(strFileName)
x = ShellEx(Form1.hwnd, "open", strFileName, "", "", 1)
End Sub
'>>>>>>>>>>>>>>>>> code for event on form <<<<<<<<<<<<<<<<<<<<<<<<<<
'
in the list click event
Dim MyFile$
MyFile$ = list1.text 'if list1.text is your file name and extension
ShellDef MyFile$
Very good. Thanks.