View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default VBA Code== Goto a webpage using a command button in a UserForm

I want to write a code so when I press a command button in a userform it will
take me to a particular website.. Anyone know how to do this??

Thanks


You can do this using the ShellExecute API...


Put this in your Declaration section of the code module:
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


Put this in the macro that runs when you click the button:
ShellExecute 0&, vbNullString, "URL http info" vbNullString,
vbNullString, vbNormalFocus

...where the full URL is passed as a string value in the 3rd arg. Note
that the macro should be in the same code module as the API declaration
because its scope is 'Private'. If you want several sheets to use the
same API then put it in a standard module and change its scope to
'Public'.

--
Garry

Free uenet access at http://www.eternal-september.org
Classic VB Users Regroup
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion