i want to open a webpage in internet explorer when a button is pushed. how do i do this?
i want to open a webpage in internet explorer when a button is pushed. how do i do this?
Use this handy little snippet :)
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 Declare Function GetDesktopWindow Lib "user32" () As Long Public Sub StartDoc(ByVal DocName As String) ShellExecute GetDesktopWindow(), "Open", DocName, "", "C:\", 1 End Sub
You would call it as follows :
VB Code:
Private Sub Command1_Click StartDoc "http://www.vbforums.com" End Sub
you would have more control over your explorer session if, instead of launching it in a shell, you would open it as an automation object. you would have to add a "Microsoft Internet Controls" reference to your project (see the Project > References menu), declare and instantiate an object as
and so on. depends on what you need.VB Code:
Dim brow As InternetExplorer Set brow = New InternetExplorer
One could also add it as a component and let VB instantiate it instead of you having to do the work :)