Results 1 to 4 of 4

Thread: what is the shell command to open an internet explorer window?

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2002
    Location
    long island, new york
    Posts
    32

    what is the shell command to open an internet explorer window?

    i want to open a webpage in internet explorer when a button is pushed. how do i do this?

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Use this handy little snippet

    VB Code:
    1. 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
    2. Private Declare Function GetDesktopWindow Lib "user32" () As Long
    3.  
    4. Public Sub StartDoc(ByVal DocName As String)
    5.     ShellExecute GetDesktopWindow(), "Open", DocName, "", "C:\", 1
    6. End Sub

    You would call it as follows :

    VB Code:
    1. Private Sub Command1_Click
    2.     StartDoc "http://www.vbforums.com"
    3. End Sub
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Fanatic Member
    Join Date
    Feb 2003
    Location
    Los Angeles, CA
    Posts
    681
    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
    VB Code:
    1. Dim brow As InternetExplorer
    2. Set brow = New InternetExplorer
    and so on. depends on what you need.

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    One could also add it as a component and let VB instantiate it instead of you having to do the work
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width