Hi everyone..
I hope you can help me with this..
How could you open a file with its default program from a File List or a list box.
For example, if this is ".doc" then it should open with Microsoft Word ....
bye... and thanx..... betto :)
Printable View
Hi everyone..
I hope you can help me with this..
How could you open a file with its default program from a File List or a list box.
For example, if this is ".doc" then it should open with Microsoft Word ....
bye... and thanx..... betto :)
When you receive from the user the file name and extension just use the shell command
shell "path_to_the_file\FileName.Ext"
shell knows what app to call... ;)
I tried the Shell Function... but it says "File not Found"...., later.. in the VB Help, it said, it run EXECUTABLE programs(only .exe) :( , see?...
anyway... i needed it for other programs :cool:
If it says "File not found", then the file really was not found. I tested it. You should get a "Invalid procedure call or argument" message if the filepath is correct.
try this in a module or something
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
lngResult = ShellExecute(Me.hwnd, "Open", strFile, "", "", vbNormalFocus)
Thank you HAVocINCARNATE29, your function really worked... and really good... and thanks to you too Kedaman, but i checked the path with the immediate and it was right... thanks anyway.... this site is cool!!!! :cool: and nice.. bye
betto :)
i did what you suggested, but for some reason it only allows me to open*.txt files...any suggestions?