Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executing files

Status
Not open for further replies.

MarcoMB

Programmer
Oct 24, 2006
61
IT
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top