+ Reply to Thread
Results 1 to 6 of 6

In VBA, make IE Browser object always in foreground

  1. #1
    gary
    Guest

    In VBA, make IE Browser object always in foreground

    I use VBA to create an IE Browser object using code shown below.
    Sometimes the browser comes up minimized and shows flashing in the task bar
    at the bottom of the screen due to other activities on the screen.

    I need to have the ie object always visible. Is there a command I can use
    to make this happen ?


    Set ie = CreateObject("InternetExplorer.Application")
    ie.AddressBar = False
    ie.MenuBar = False
    ie.Toolbar = False
    ie.Width = ScreenWidth * 0.55 ' 600
    ie.Height = ScreenHeight * 0.98 '750
    ie.Left = 0
    ie.Top = 0

    Thanks,

    Gary


  2. #2
    Chip Pearson
    Guest

    Re: In VBA, make IE Browser object always in foreground

    You need to add

    IE.Visible = True

    to make the browser visible in the first place. To keep the
    browser visible within Excel, allowing you to switch between IE
    and Excel without losing the browser, you need to use the
    SetParent API call.

    In the declarations area of your module (above and outside of any
    procedure), declare the SetParent function.

    Declare Function SetParent Lib "user32" (ByVal hWndChild As Long,
    _
    ByVal hWndNewParent As Long) As Long

    Then, in your procedure, use code like

    IE.Visible = True
    SetParent IE.Hwnd, Application.Hwnd

    This will make IE a child window of the Excel application, and IE
    will float above the worksheet.

    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "gary" <gary@discussions.microsoft.com> wrote in message
    news:30A00537-733D-42CE-BD8D-2F6CA7D73B5A@microsoft.com...
    >I use VBA to create an IE Browser object using code shown below.
    > Sometimes the browser comes up minimized and shows flashing in
    > the task bar
    > at the bottom of the screen due to other activities on the
    > screen.
    >
    > I need to have the ie object always visible. Is there a
    > command I can use
    > to make this happen ?
    >
    >
    > Set ie = CreateObject("InternetExplorer.Application")
    > ie.AddressBar = False
    > ie.MenuBar = False
    > ie.Toolbar = False
    > ie.Width = ScreenWidth * 0.55 ' 600
    > ie.Height = ScreenHeight * 0.98 '750
    > ie.Left = 0
    > ie.Top = 0
    >
    > Thanks,
    >
    > Gary
    >




  3. #3
    gary
    Guest

    Re: In VBA, make IE Browser object always in foreground

    Hi Chip,

    Your suggestion worked great with one small mod. I had to Add “Private” in
    front of the declare SetParent function so as to not get the “..Declare
    statements not allowed as public members of object modules” error. I don’t
    understand what this message is telling me. But your suggest worked great.

    Many thanks,

    Gary
    decalre teh

    "Chip Pearson" wrote:

    > You need to add
    >
    > IE.Visible = True
    >
    > to make the browser visible in the first place. To keep the
    > browser visible within Excel, allowing you to switch between IE
    > and Excel without losing the browser, you need to use the
    > SetParent API call.
    >
    > In the declarations area of your module (above and outside of any
    > procedure), declare the SetParent function.
    >
    > Declare Function SetParent Lib "user32" (ByVal hWndChild As Long,
    > _
    > ByVal hWndNewParent As Long) As Long
    >
    > Then, in your procedure, use code like
    >
    > IE.Visible = True
    > SetParent IE.Hwnd, Application.Hwnd
    >
    > This will make IE a child window of the Excel application, and IE
    > will float above the worksheet.
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    > "gary" <gary@discussions.microsoft.com> wrote in message
    > news:30A00537-733D-42CE-BD8D-2F6CA7D73B5A@microsoft.com...
    > >I use VBA to create an IE Browser object using code shown below.
    > > Sometimes the browser comes up minimized and shows flashing in
    > > the task bar
    > > at the bottom of the screen due to other activities on the
    > > screen.
    > >
    > > I need to have the ie object always visible. Is there a
    > > command I can use
    > > to make this happen ?
    > >
    > >
    > > Set ie = CreateObject("InternetExplorer.Application")
    > > ie.AddressBar = False
    > > ie.MenuBar = False
    > > ie.Toolbar = False
    > > ie.Width = ScreenWidth * 0.55 ' 600
    > > ie.Height = ScreenHeight * 0.98 '750
    > > ie.Left = 0
    > > ie.Top = 0
    > >
    > > Thanks,
    > >
    > > Gary
    > >

    >
    >
    >


  4. #4
    Chip Pearson
    Guest

    Re: In VBA, make IE Browser object always in foreground

    In class modules, Sheet modules, and the ThisWorkbook module,
    function declares may not be Public. You must declare them as
    Private. Just one of the rules of the road.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "gary" <gary@discussions.microsoft.com> wrote in message
    news:8BD17699-3FB0-4EAF-AB0A-7CEA2DABFD2E@microsoft.com...
    > Hi Chip,
    >
    > Your suggestion worked great with one small mod. I had to Add
    > "Private" in
    > front of the declare SetParent function so as to not get the
    > "..Declare
    > statements not allowed as public members of object modules"
    > error. I don't
    > understand what this message is telling me. But your suggest
    > worked great.
    >
    > Many thanks,
    >
    > Gary
    > decalre teh
    >
    > "Chip Pearson" wrote:
    >
    >> You need to add
    >>
    >> IE.Visible = True
    >>
    >> to make the browser visible in the first place. To keep the
    >> browser visible within Excel, allowing you to switch between
    >> IE
    >> and Excel without losing the browser, you need to use the
    >> SetParent API call.
    >>
    >> In the declarations area of your module (above and outside of
    >> any
    >> procedure), declare the SetParent function.
    >>
    >> Declare Function SetParent Lib "user32" (ByVal hWndChild As
    >> Long,
    >> _
    >> ByVal hWndNewParent As Long) As Long
    >>
    >> Then, in your procedure, use code like
    >>
    >> IE.Visible = True
    >> SetParent IE.Hwnd, Application.Hwnd
    >>
    >> This will make IE a child window of the Excel application, and
    >> IE
    >> will float above the worksheet.
    >>
    >> --
    >> Cordially,
    >> Chip Pearson
    >> Microsoft MVP - Excel
    >> Pearson Software Consulting, LLC
    >> www.cpearson.com
    >>
    >>
    >>
    >> "gary" <gary@discussions.microsoft.com> wrote in message
    >> news:30A00537-733D-42CE-BD8D-2F6CA7D73B5A@microsoft.com...
    >> >I use VBA to create an IE Browser object using code shown
    >> >below.
    >> > Sometimes the browser comes up minimized and shows flashing
    >> > in
    >> > the task bar
    >> > at the bottom of the screen due to other activities on the
    >> > screen.
    >> >
    >> > I need to have the ie object always visible. Is there a
    >> > command I can use
    >> > to make this happen ?
    >> >
    >> >
    >> > Set ie = CreateObject("InternetExplorer.Application")
    >> > ie.AddressBar = False
    >> > ie.MenuBar = False
    >> > ie.Toolbar = False
    >> > ie.Width = ScreenWidth * 0.55 ' 600
    >> > ie.Height = ScreenHeight * 0.98 '750
    >> > ie.Left = 0
    >> > ie.Top = 0
    >> >
    >> > Thanks,
    >> >
    >> > Gary
    >> >

    >>
    >>
    >>




  5. #5
    gary
    Guest

    Re: In VBA, make IE Browser object always in foreground

    Chip,

    I noticed that although the IE browser is on top, I can not move it or
    adjust the scroll bars. If I comment out the “SetParent IE.Hwnd,
    Application.Hwnd” then I can move the window and adjust the scroll bars.

    Is it possible to have the browser window on top AND still be able to
    control the scroll bars and move the window.

    Hope this makes sense,

    Gary


    "Chip Pearson" wrote:

    > In class modules, Sheet modules, and the ThisWorkbook module,
    > function declares may not be Public. You must declare them as
    > Private. Just one of the rules of the road.
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    > "gary" <gary@discussions.microsoft.com> wrote in message
    > news:8BD17699-3FB0-4EAF-AB0A-7CEA2DABFD2E@microsoft.com...
    > > Hi Chip,
    > >
    > > Your suggestion worked great with one small mod. I had to Add
    > > "Private" in
    > > front of the declare SetParent function so as to not get the
    > > "..Declare
    > > statements not allowed as public members of object modules"
    > > error. I don't
    > > understand what this message is telling me. But your suggest
    > > worked great.
    > >
    > > Many thanks,
    > >
    > > Gary
    > > decalre teh
    > >
    > > "Chip Pearson" wrote:
    > >
    > >> You need to add
    > >>
    > >> IE.Visible = True
    > >>
    > >> to make the browser visible in the first place. To keep the
    > >> browser visible within Excel, allowing you to switch between
    > >> IE
    > >> and Excel without losing the browser, you need to use the
    > >> SetParent API call.
    > >>
    > >> In the declarations area of your module (above and outside of
    > >> any
    > >> procedure), declare the SetParent function.
    > >>
    > >> Declare Function SetParent Lib "user32" (ByVal hWndChild As
    > >> Long,
    > >> _
    > >> ByVal hWndNewParent As Long) As Long
    > >>
    > >> Then, in your procedure, use code like
    > >>
    > >> IE.Visible = True
    > >> SetParent IE.Hwnd, Application.Hwnd
    > >>
    > >> This will make IE a child window of the Excel application, and
    > >> IE
    > >> will float above the worksheet.
    > >>
    > >> --
    > >> Cordially,
    > >> Chip Pearson
    > >> Microsoft MVP - Excel
    > >> Pearson Software Consulting, LLC
    > >> www.cpearson.com
    > >>
    > >>
    > >>
    > >> "gary" <gary@discussions.microsoft.com> wrote in message
    > >> news:30A00537-733D-42CE-BD8D-2F6CA7D73B5A@microsoft.com...
    > >> >I use VBA to create an IE Browser object using code shown
    > >> >below.
    > >> > Sometimes the browser comes up minimized and shows flashing
    > >> > in
    > >> > the task bar
    > >> > at the bottom of the screen due to other activities on the
    > >> > screen.
    > >> >
    > >> > I need to have the ie object always visible. Is there a
    > >> > command I can use
    > >> > to make this happen ?
    > >> >
    > >> >
    > >> > Set ie = CreateObject("InternetExplorer.Application")
    > >> > ie.AddressBar = False
    > >> > ie.MenuBar = False
    > >> > ie.Toolbar = False
    > >> > ie.Width = ScreenWidth * 0.55 ' 600
    > >> > ie.Height = ScreenHeight * 0.98 '750
    > >> > ie.Left = 0
    > >> > ie.Top = 0
    > >> >
    > >> > Thanks,
    > >> >
    > >> > Gary
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >


  6. #6
    Chip Pearson
    Guest

    Re: In VBA, make IE Browser object always in foreground

    I can't replicate your problem The code I provided works fine in
    Excel 2003 and IE 6.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "gary" <gary@discussions.microsoft.com> wrote in message
    news:3010C4E6-81A3-4673-8608-D602E0FA4A14@microsoft.com...
    > Chip,
    >
    > I noticed that although the IE browser is on top, I can not
    > move it or
    > adjust the scroll bars. If I comment out the "SetParent
    > IE.Hwnd,
    > Application.Hwnd" then I can move the window and adjust the
    > scroll bars.
    >
    > Is it possible to have the browser window on top AND still be
    > able to
    > control the scroll bars and move the window.
    >
    > Hope this makes sense,
    >
    > Gary
    >
    >
    > "Chip Pearson" wrote:
    >
    >> In class modules, Sheet modules, and the ThisWorkbook module,
    >> function declares may not be Public. You must declare them as
    >> Private. Just one of the rules of the road.
    >>
    >>
    >> --
    >> Cordially,
    >> Chip Pearson
    >> Microsoft MVP - Excel
    >> Pearson Software Consulting, LLC
    >> www.cpearson.com
    >>
    >>
    >>
    >> "gary" <gary@discussions.microsoft.com> wrote in message
    >> news:8BD17699-3FB0-4EAF-AB0A-7CEA2DABFD2E@microsoft.com...
    >> > Hi Chip,
    >> >
    >> > Your suggestion worked great with one small mod. I had to
    >> > Add
    >> > "Private" in
    >> > front of the declare SetParent function so as to not get the
    >> > "..Declare
    >> > statements not allowed as public members of object modules"
    >> > error. I don't
    >> > understand what this message is telling me. But your
    >> > suggest
    >> > worked great.
    >> >
    >> > Many thanks,
    >> >
    >> > Gary
    >> > decalre teh
    >> >
    >> > "Chip Pearson" wrote:
    >> >
    >> >> You need to add
    >> >>
    >> >> IE.Visible = True
    >> >>
    >> >> to make the browser visible in the first place. To keep the
    >> >> browser visible within Excel, allowing you to switch
    >> >> between
    >> >> IE
    >> >> and Excel without losing the browser, you need to use the
    >> >> SetParent API call.
    >> >>
    >> >> In the declarations area of your module (above and outside
    >> >> of
    >> >> any
    >> >> procedure), declare the SetParent function.
    >> >>
    >> >> Declare Function SetParent Lib "user32" (ByVal hWndChild As
    >> >> Long,
    >> >> _
    >> >> ByVal hWndNewParent As Long) As Long
    >> >>
    >> >> Then, in your procedure, use code like
    >> >>
    >> >> IE.Visible = True
    >> >> SetParent IE.Hwnd, Application.Hwnd
    >> >>
    >> >> This will make IE a child window of the Excel application,
    >> >> and
    >> >> IE
    >> >> will float above the worksheet.
    >> >>
    >> >> --
    >> >> Cordially,
    >> >> Chip Pearson
    >> >> Microsoft MVP - Excel
    >> >> Pearson Software Consulting, LLC
    >> >> www.cpearson.com
    >> >>
    >> >>
    >> >>
    >> >> "gary" <gary@discussions.microsoft.com> wrote in message
    >> >> news:30A00537-733D-42CE-BD8D-2F6CA7D73B5A@microsoft.com...
    >> >> >I use VBA to create an IE Browser object using code shown
    >> >> >below.
    >> >> > Sometimes the browser comes up minimized and shows
    >> >> > flashing
    >> >> > in
    >> >> > the task bar
    >> >> > at the bottom of the screen due to other activities on
    >> >> > the
    >> >> > screen.
    >> >> >
    >> >> > I need to have the ie object always visible. Is there a
    >> >> > command I can use
    >> >> > to make this happen ?
    >> >> >
    >> >> >
    >> >> > Set ie = CreateObject("InternetExplorer.Application")
    >> >> > ie.AddressBar = False
    >> >> > ie.MenuBar = False
    >> >> > ie.Toolbar = False
    >> >> > ie.Width = ScreenWidth * 0.55 ' 600
    >> >> > ie.Height = ScreenHeight * 0.98 '750
    >> >> > ie.Left = 0
    >> >> > ie.Top = 0
    >> >> >
    >> >> > Thanks,
    >> >> >
    >> >> > Gary
    >> >> >
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>




+ 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.6.0 RC 1