Click to See Complete Forum and Search --> : File Associations


deane
October 29th, 1999, 10:31 AM
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.

October 29th, 1999, 02:52 PM
'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$

deane
October 29th, 1999, 03:44 PM
Very good. Thanks.