[RESOLVED] opening files via commandbutton
I'm trying to find the code to have a web page open from a command button.
specifically, when I simply press a button on one of my sheets, I want IE to launch and a specific web page to load. (this site is one of them actually).
I can get excel sheet to load this way but I havent been able to get web pages to load yet. any help would be appreciated.
Re: opening files via commandbutton
Try the following
VB Code:
Private 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
Private Sub Command1_Click()
Dim r As Long
r = ShellExecute(0, "open", "WWW.YourWebAddressHere.COM", 0, 0, 1)
End Sub
Re: opening files via commandbutton
My mistake. I specified a commandbutton but neglected to specifcy that I'm using excel.
I tried adding in the code supplied but getting compile errors.
Re: opening files via commandbutton
Have you added the Private Declare Function statement at the top of the module? it need to be before any procedure?
I ran this in excel and it worked fine.
Re: opening files via commandbutton
That worked this time. thank you!