excel internet explorer interaction appearance

Discussion in 'Microsoft Excel Programming' started by Walter Briscoe, Jul 2, 2009.

  1. I am running Excel 2003, IE7, and XP SP3

    (I have learnt how to get information from IE from examples posted by
    Joel <>.)

    Excel VBA interacts with IE with IE.visible = False as the user does not
    need to see that interaction.
    The windows start bar sometimes shows briefly during such interaction.
    More briefly, the IE window outline appears.
    What mechanisms cause such transient behavior?
    How can I code to achieve consistent behavior?
    n.b. IE.visible = True is not acceptable!

    Most of the time the interaction is automatic. When user intervention is
    necessary, I use IE.visible = True to allow that intervention and an
    Excel VBA MsgBox call to allow my code to wait until the user signals
    the intervention is complete. I tried putting a doevents call in the
    middle to see if I could get the behavior I want which is for the MsgBox
    to be visible and for the focus to be on IE. (Excel is full screen and
    IE is in a 500 pixel wide window.)
    So far I have seen two scenarios:
    1) IE has the focus and Excel flashes to show the user needs to act.
    When I give Excel focus, the MsgBox appears;
    2) Excel retains focus, the MsgBox appears and IE flahes for attention.

    This is a fairly obvious race condition.
    What can I do to avoid that race condition?

    I say again, My code is:
    ' IE.busy is false
    IE.visible = True ' Unhide IE window
    doevents ' Give control to IE etc.
    MsgBox "Do something with IE!" ' Let the user say IE is ready again
    IE.visible = False ' Hide IE window

    My understanding of Excel/IE interaction is still naive.
    I would value suggestions on good (ideally free) places to read.
    --
    Walter Briscoe
     
    Walter Briscoe, Jul 2, 2009
    #1
    1. Advertisements

  2. Walter Briscoe

    r Guest

    try ...

    Option Explicit
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    Sub test_IE()
    Dim myURL As String
    Dim myIE As Object
    Const READYSTATE_COMPLETE As Long = 4

    Set myIE = CreateObject("InternetExplorer.Application")
    myURL = "http://www.google.com"

    myIE.Visible = True

    myIE.navigate myURL

    Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
    DoEvents
    Sleep 500
    Loop

    'myIE.Quit
    End Sub



    Sub test_IE_2_not_visible()
    Dim myURL As String
    Dim myIE As Object
    Const READYSTATE_COMPLETE As Long = 4

    Set myIE = CreateObject("InternetExplorer.Application")
    myURL = "http://www.google.com"

    'myIE.Visible = True

    myIE.navigate myURL

    Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
    DoEvents
    Sleep 500
    Loop

    myIE.Quit
    End Sub

    regards
    r

    Il mio ultimo lavoro ...
    http://excelvba.altervista.org/blog/index.php/Excel-VBA/UsedRange-eccezioni-e-alternative.html


    "Walter Briscoe" wrote:

    > I am running Excel 2003, IE7, and XP SP3
    >
    > (I have learnt how to get information from IE from examples posted by
    > Joel <>.)
    >
    > Excel VBA interacts with IE with IE.visible = False as the user does not
    > need to see that interaction.
    > The windows start bar sometimes shows briefly during such interaction.
    > More briefly, the IE window outline appears.
    > What mechanisms cause such transient behavior?
    > How can I code to achieve consistent behavior?
    > n.b. IE.visible = True is not acceptable!
    >
    > Most of the time the interaction is automatic. When user intervention is
    > necessary, I use IE.visible = True to allow that intervention and an
    > Excel VBA MsgBox call to allow my code to wait until the user signals
    > the intervention is complete. I tried putting a doevents call in the
    > middle to see if I could get the behavior I want which is for the MsgBox
    > to be visible and for the focus to be on IE. (Excel is full screen and
    > IE is in a 500 pixel wide window.)
    > So far I have seen two scenarios:
    > 1) IE has the focus and Excel flashes to show the user needs to act.
    > When I give Excel focus, the MsgBox appears;
    > 2) Excel retains focus, the MsgBox appears and IE flahes for attention.
    >
    > This is a fairly obvious race condition.
    > What can I do to avoid that race condition?
    >
    > I say again, My code is:
    > ' IE.busy is false
    > IE.visible = True ' Unhide IE window
    > doevents ' Give control to IE etc.
    > MsgBox "Do something with IE!" ' Let the user say IE is ready again
    > IE.visible = False ' Hide IE window
    >
    > My understanding of Excel/IE interaction is still naive.
    > I would value suggestions on good (ideally free) places to read.
    > --
    > Walter Briscoe
    >
     
    r, Jul 2, 2009
    #2
    1. Advertisements

  3. In message <> of Thu,
    2 Jul 2009 06:58:01 in microsoft.public.excel.programming, r
    <> writes
    >
    >try ...
    >
    >Option Explicit
    >Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    >
    >Sub test_IE()


    [snip]

    >myIE.navigate myURL
    >
    >Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
    > DoEvents
    > Sleep 500
    >Loop
    >
    >'myIE.Quit
    >End Sub


    [snip]

    I did and still have a race condition. ;(
    Sometimes the Excel Msgbox has focus and sometimes IE.

    However, I am really excited to have access to Sleep(). ;)
    I had failed to find anything in VBA help for sleep, delay, timer, etc.
    Your showing a hook to "standard" MS library functions gives me power!

    What I want is:
    Excel has a MsgBox on top of a fullscreen window.
    IE is visible and has focus.
    I am prepared to accept that I can't get what I want.
    It would probably need threads of control in Excel and, even if that was
    possible, the reward would not justify the effort.

    [snip]

    >
    >regards
    >r
    >
    >Il mio ultimo lavoro ...
    >http://excelvba.altervista.org/blog/index.php/Excel-VBA/UsedRange-
    >eccezioni-e-alternative.html


    I did look at in in Babelfish, but did NOT understand your intention.
    I DID see you use vbscript.regexp. I am familiar with UNIX regular
    expressions and find them very helpful. It was a revelation to me that
    such functionality is easily found from VBA.

    [snip]

    Scuzzi, no parliamo Italiano!
    Molto grazie!
    --
    Walter Briscoe
     
    Walter Briscoe, Jul 2, 2009
    #3
  4. Walter Briscoe

    r Guest

    you could use a UserForm modaless ...
    it is easy to build one similar to a msgbox

    try ...

    Sub test_IE()
    Dim myURL As String
    Dim myie As Object
    Const READYSTATE_COMPLETE As Long = 4

    Set myie = CreateObject("InternetExplorer.Application")
    myURL = "http://www.google.com"


    myie.Navigate myURL

    Do While myie.Busy Or myie.readyState <> READYSTATE_COMPLETE
    DoEvents
    Sleep 500
    Loop

    UserForm1.Show 0
    myie.Visible = True

    'myIE.Quit
    End Sub

    --
    Come e dove incollare il codice:
    http://www.rondebruin.nl/code.htm

    Il mio ultimo lavoro ...
    http://excelvba.altervista.org/blog/index.php/Excel-VBA/UsedRange-eccezioni-e-alternative.html


    "Walter Briscoe" wrote:

    > In message <> of Thu,
    > 2 Jul 2009 06:58:01 in microsoft.public.excel.programming, r
    > <> writes
    > >
    > >try ...
    > >
    > >Option Explicit
    > >Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    > >
    > >Sub test_IE()

    >
    > [snip]
    >
    > >myIE.navigate myURL
    > >
    > >Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
    > > DoEvents
    > > Sleep 500
    > >Loop
    > >
    > >'myIE.Quit
    > >End Sub

    >
    > [snip]
    >
    > I did and still have a race condition. ;(
    > Sometimes the Excel Msgbox has focus and sometimes IE.
    >
    > However, I am really excited to have access to Sleep(). ;)
    > I had failed to find anything in VBA help for sleep, delay, timer, etc.
    > Your showing a hook to "standard" MS library functions gives me power!
    >
    > What I want is:
    > Excel has a MsgBox on top of a fullscreen window.
    > IE is visible and has focus.
    > I am prepared to accept that I can't get what I want.
    > It would probably need threads of control in Excel and, even if that was
    > possible, the reward would not justify the effort.
    >
    > [snip]
    >
    > >
    > >regards
    > >r
    > >
    > >Il mio ultimo lavoro ...
    > >http://excelvba.altervista.org/blog/index.php/Excel-VBA/UsedRange-
    > >eccezioni-e-alternative.html

    >
    > I did look at in in Babelfish, but did NOT understand your intention.
    > I DID see you use vbscript.regexp. I am familiar with UNIX regular
    > expressions and find them very helpful. It was a revelation to me that
    > such functionality is easily found from VBA.
    >
    > [snip]
    >
    > Scuzzi, no parliamo Italiano!
    > Molto grazie!
    > --
    > Walter Briscoe
    >
     
    r, Jul 2, 2009
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. stuart

    excel/website interaction PLEASE HELP!!

    stuart, Aug 7, 2003, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    242
  2. wijwoj
    Replies:
    0
    Views:
    345
    wijwoj
    Oct 30, 2003
  3. ibeetb

    Run Excel Report on Server w/out human interaction

    ibeetb, Feb 5, 2004, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    211
  4. Ron

    Excel - web page interaction...is it possible?

    Ron, Jun 20, 2004, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    349
    madcat
    Jun 25, 2004
  5. Ron

    Interaction with Internet Explorer

    Ron, Feb 3, 2005, in forum: Microsoft Excel Programming
    Replies:
    8
    Views:
    296
    PaulD
    Feb 5, 2005
Loading...

Share This Page