+ Reply to Thread
Results 1 to 3 of 3

Thread: Launching a web browser from excel

  1. #1
    Registered User
    Join Date
    05-26-2010
    Location
    Kentucky
    MS-Off Ver
    Excel 2010
    Posts
    31

    Launching a web browser from excel

    Back again,

    I'm wanting to launch a web browser from an excel worksheet. I've got some code that _mostly_ works...

    Sub Button_PS_Login()
    
    Dim Site As Object
    
    Set Site = CreateObject("InternetExplorer.application")
    Site.Visible = True
    Site.Navigate "http://www.cnn.com"
    
    End Sub
    I'd like the window to pop on top, even if another browser is running minimized. When I run this code, I don't always get the new window to pop up, sometimes I just get the nice glowing icon at the bottom that indicates something needs attention. Is there some sort of "on top" flag I can define?

    Thanks!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Launching a web browser from excel

    Hello GordonPSmith,

    This will automatically maximize the window after Internet Explorer is tarted.
    
    ' This line must appear above before any Sub or Function statements in the VBA module.
    Private Declare Function ShowWindow Lib "User32.dll" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
    
    
    Sub Button_PS_Login()
    
        Dim Site As Object
    
            Set Site = CreateObject("InternetExplorer.application")
            Site.Visible = True
            Site.Navigate "http://www.cnn.com"
            
            ShowWindow Site.hWnd, 3
    
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Launching a web browser from excel

    I don't know what 'tarting' is (only a wild guess) but:

    Sub snb()
     With CreateObject("InternetExplorer.application")
      .Visible = True
      .FullScreen = True
      .Navigate "http://www.cnn.com"
     End With
    End Sub
    Last edited by snb; 01-06-2012 at 02:57 PM.



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0