ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Tell if workbook is opened in IE (https://www.excelbanter.com/excel-programming/321758-tell-if-workbook-opened-ie.html)

jnc[_3_]

Tell if workbook is opened in IE
 
Hey Guys,

I was wondering if there is a way I can tell if a workbook that has been
opened is hosted in Interner Explorer.

Ideally what I would like to do is checked if the workbook/ excel
application is hosted in IE on one of the Applciation start up events and
then disable some off my code accordingly.

Thanks for you help.

Regards........Jim





Robert Doisneau

Tell if workbook is opened in IE
 
I was wondering if there is a way I can tell if a workbook that has
been opened is hosted in Interner Explorer.

I'd love to know this as well.





Dave Peterson[_5_]

Tell if workbook is opened in IE
 
In another forum, Jim Rech suggested using ActiveWorkbook.Container.

Ture Magnusson posted this using Jim's suggestion:

Thanks Jim!

Container works perfectly...

Sub CheckIfInInternetExplorer()
'Declare local variable
Dim x As Object

'Try to get container object
On Error Resume Next
Set x = ActiveWorkbook.Container
On Error GoTo 0

'Show result depending on container's typename
Select Case TypeName(x)
Case "Nothing"
MsgBox "The workbook is opened in Excel"
Case "IWebBrowser2"
MsgBox "The workbook is opened in Internet Explorer"
Case Else
MsgBox "The workbook is opened in another application: " & TypeName(x)
End Select

'Clear object variable
Set x = Nothing
End Sub

/Ture


jnc wrote:

Hey Guys,

I was wondering if there is a way I can tell if a workbook that has been
opened is hosted in Interner Explorer.

Ideally what I would like to do is checked if the workbook/ excel
application is hosted in IE on one of the Applciation start up events and
then disable some off my code accordingly.

Thanks for you help.

Regards........Jim


--

Dave Peterson


All times are GMT +1. The time now is 10:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com