Discussion:
Check in vba if html document is already open.
(too old to reply)
Chris Watts
2009-08-26 15:32:36 UTC
Permalink
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
Karl E. Peterson
2009-09-02 17:35:14 UTC
Permalink
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.
--
.NET: It's About Trust!
http://vfred.mvps.org
Steve Rindsberg
2009-09-03 15:16:07 UTC
Permalink
Post by Karl E. Peterson
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.
What about hosting an MSIE control on a form instead?
Chris Watts
2009-09-03 17:47:19 UTC
Permalink
Post by Steve Rindsberg
Post by Karl E. Peterson
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.
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
Steve Rindsberg
2009-09-03 20:24:15 UTC
Permalink
Post by Chris Watts
Post by Steve Rindsberg
Post by Karl E. Peterson
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.
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!>
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>
Karl E. Peterson
2009-09-04 23:08:38 UTC
Permalink
Post by Steve Rindsberg
Post by Karl E. Peterson
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.
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.
--
.NET: It's About Trust!
http://vfred.mvps.org
Steve Rindsberg
2009-09-05 17:17:08 UTC
Permalink
Post by Karl E. Peterson
Post by Steve Rindsberg
Post by Karl E. Peterson
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.
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.
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.
Karl E. Peterson
2009-09-08 21:58:53 UTC
Permalink
Post by Steve Rindsberg
Post by Karl E. Peterson
Post by Steve Rindsberg
Post by Karl E. Peterson
Post by Chris Watts
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.
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.
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.
--
.NET: It's About Trust!
http://vfred.mvps.org
Loading...