Link to home
Create AccountLog in
Microsoft Excel

Microsoft Excel

--

Questions

--

Followers

Top Experts

Avatar of Robert Berke
Robert Berke🇺🇸

How can Excel vba tell if it is being executed under Internet Explorer?
I just learned how to count the Excel instances that are open ( http://www-new.experts-exchange.com/questions/22130186/Vba-to-see-if-two-instances-of-excel-are-running.html)

I now need to tell if one of those instances is running under Internet Explorer.  

Is there any way?

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


ASKER CERTIFIED SOLUTION
Avatar of Rory ArchibaldRory Archibald🇬🇧

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of Robert BerkeRobert Berke🇺🇸

ASKER

For this question I only care about the specific instance. In other words, I do not care about any other threads that using Excel.

Ideally my vba functions should not do anything when running under any web browser. But, everyone here uses IE 6 or IE 7, so that might simplify things.

Something like this pseudo code:

if ThisWorkbook is RunningUnderAnyBrowser then exit function.


Avatar of Rory ArchibaldRory Archibald🇬🇧

Check the ThisWorkbook.Container.Name - if Excel is running normally, this will cause an error; if under IE, it should return "Microsoft Internet Explorer" (or something similar) ar it will return the name of the container application if the workbook is embedded in say a Word document. I have a recollection that you can't use this directly in the Workbook_Open event - you need to use Application.Ontime with say a 1 second delay.
HTH
Rory

Avatar of Robert BerkeRobert Berke🇺🇸

ASKER

That worked great.  But, FYI,  I was wrong about using Thisworkbook.
Here is what I had to do instead.  
    on error resume next
    For Each Workbook In Application.Workbooks
       x = Workbook.Container.Name
        If Not IsEmpty(x) Then GoTo exitsub
    Next Workbook
Thanks a ton

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of Rory ArchibaldRory Archibald🇬🇧

Glad it worked!
Rory.

Avatar of Robert BerkeRobert Berke🇺🇸

ASKER

related questions are Q_22130186 Q_22130644 and  Q_22129061

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.

Microsoft Excel

Microsoft Excel

--

Questions

--

Followers

Top Experts

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.