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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open file in its own application 1

Status
Not open for further replies.

MatthewP

Programmer
Jan 16, 2001
176
0
0
GB
There's got to be an easy way to do this.. I just want a button in a program to open a file in it's own application - eg if I point to a .html file in the code, it will open in whatever browser the user has set as default.

Thanks,
Matt.
 
Code:
Public 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

Dim lng_retValue As Long
lng_retValue = ShellExecute(0, "open", "[URL unfurl="true"]http://mywebsite/page",[/URL] "", 0, 1)

Mark
 
Wow, bit more code than I thought!

Thanks for your help,
Matt.
 
Two declarations and one line of code is too much??!! <grin>
 
How is this for easier...
Code:
private sub Command_Click()
   Shell (&quot;start [URL unfurl="true"]http://www.webpage.com&quot;)[/URL]
end sub
If that isn't easy enough then I can not help much more.


Give that one a try Mavors
Cincinnati, Ohio
 
Perfect! No, 2 declarations and one line isn't too much, I just figured there had to be something really simple that I'd missed - and there it is!

Thanks all,
Matt.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top