in a listbox control i have a list of filename with differnt extensions...i would like execute them in the listbox event click as if i execute them from windows explorer...how can i do?ther's an file execute method in visual basic?
You need to use Shell. Lot's of examples in this forum. You don't need to worry about the application, just give it the filename and windows will run it with the right application (or at least probably some application!).
... or even easier use Shell with rundll.exe as it's argument. My standard function for this:
Code:
Public Function OpenDocument(DocumentWithPath As String) As Long
OpenDocument = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocumentWithPath, vbNormalFocus)
End Function
Works on any file that has a default application registered on users machine
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?' Drive a Steam Roller
thanks, i found easily the solution in MSDN using SHELL, but what about executing non EXE files like explorer do giving the choice of what application to use for opening file such as .txt,etc?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.