Check in vba if html document is already open.

C

Chris Watts

Hi!
I have an Excel vba macro that opens an html document in IE. I want to be
able
have the macro check if the document is already open or not; if it is open
then I
want to switch the focus to it rather than open another instance How can I
achieve this? It is not sufficient to check if IE is running as the user
may have other websites open at the time.

TIA
Chris
 
K

Karl E. Peterson

Chris said:
I have an Excel vba macro that opens an html document in IE. I want to be able
have the macro check if the document is already open or not; if it is open then I
want to switch the focus to it rather than open another instance How can I
achieve this? It is not sufficient to check if IE is running as the user
may have other websites open at the time.

Not to mention other browsers. There's no way to be absolutely positive about this
under any theory I'm aware of. Even individual browsers don't seem able to do what
you suggest, by simply switching active tabs to the requested document. And there's
a pretty good reason for that, given that so many documents are in fact dynamic.
The same address in no way implies the same page anymore. I'd suggest you rethink
your requirements.
 
S

Steve Rindsberg

Not to mention other browsers. There's no way to be absolutely positive about this
under any theory I'm aware of. Even individual browsers don't seem able to do what
you suggest, by simply switching active tabs to the requested document. And there's
a pretty good reason for that, given that so many documents are in fact dynamic.
The same address in no way implies the same page anymore. I'd suggest you rethink
your requirements.

What about hosting an MSIE control on a form instead?
 
C

Chris Watts

Steve Rindsberg said:
What about hosting an MSIE control on a form instead?

Ah, a familiar voice from the Powerpoint forum!
Thanks Steve
I found some useful guidance at http://vba-corner.livejournal.com/4623.html
and have got what I want to work at home.
Unfortunately when I tried it at work I found that Tools>References was
greyed out so I could not use any references to Microsoft Internet
Controls. <expletives deleted!>

cheers
Chris
 
S

Steve Rindsberg

Ah, a familiar voice from the Powerpoint forum!
Thanks Steve
I found some useful guidance at http://vba-corner.livejournal.com/4623.html
and have got what I want to work at home.
Unfortunately when I tried it at work I found that Tools>References was
greyed out so I could not use any references to Microsoft Internet
Controls. <expletives deleted!>

Hmm. Try a Microsoft Web Browser control instead.

At work, that is. May as well make sure you've got hair to tear out first. <g>
 
K

Karl E. Peterson

Steve said:
What about hosting an MSIE control on a form instead?

Heh, well sure, if you're the one displaying the information, I assumed it went
without saying you'd know whether you were repeating yourself. <g> The question
sounded like the process of having opened the initial document was outside the
control of the program being written.
 
S

Steve Rindsberg

Heh, well sure, if you're the one displaying the information, I assumed it went
without saying you'd know whether you were repeating yourself. <g> The question
sounded like the process of having opened the initial document was outside the
control of the program being written.

Could be. I was thinking along the lines of:

IF your own app is the only one likely to open this particular document then
IF you only open it in a hosted control then
Who cares what IE/the user is doing?


But if that first IF isn't a valid assumption, all bets are off.
 
K

Karl E. Peterson

Steve said:
Could be. I was thinking along the lines of:

IF your own app is the only one likely to open this particular document then
IF you only open it in a hosted control then
Who cares what IE/the user is doing?


But if that first IF isn't a valid assumption, all bets are off.

Yep, makes sense.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top