PDA

Click to See Complete Forum and Search --> : [RESOLVED] opening files via commandbutton


Albatross
Apr 25th, 2006, 10:40 AM
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.

DKenny
Apr 25th, 2006, 10:45 AM
Try the following
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

Albatross
Apr 25th, 2006, 10:58 AM
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.

DKenny
Apr 25th, 2006, 11:01 AM
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.

Albatross
Apr 25th, 2006, 11:04 AM
That worked this time. thank you!