Detecting if workbook running in IE or in Excel
Hi,
Does anyone know if it is possible to detect whether a workbook is being run under Internet Explorer or within Excel itself. I want to prevent people running my workbooks/s under IE as it seems to cause too many problems - as Dave Peterson pointed out. Instead I want to display a message telling people to follow the instructions in http://support.microsoft.com/?scid=162059 The only way I can see is to examine registry keys. But would this cause problems for people without administrative access to their PC? Is there an easy way to do this? Any help appreciated. |
Detecting if workbook running in IE or in Excel
You might see if the Workbook Container or IsInPlace properties are of any
help. -- Jim "SkylineGTR" wrote in message oups.com... | Hi, | | Does anyone know if it is possible to detect whether a workbook is | being run under Internet Explorer or within Excel itself. I want to | prevent people running my workbooks/s under IE as it seems to cause too | many problems - as Dave Peterson pointed out. Instead I want to | display a message telling people to follow the instructions in | http://support.microsoft.com/?scid=162059 | | The only way I can see is to examine registry keys. But would this | cause problems for people without administrative access to their PC? | Is there an easy way to do this? | | Any help appreciated. | |
Detecting if workbook running in IE or in Excel
You are a star Jim!
The Container property was the way to go! Word of caution though, do not try and get the Container property in Workbook_Open - does not work. You need to wait until Activate is fired, then you can determine (it seems) reliably whether you are running in IE or Excel. |
Detecting if workbook running in IE or in Excel
I also experienced problems when running in the web. As a crude workaround I incorporated If (InStr(1, fname, "//") < 0) Then msgbox(" This workbook is not configured to run via the web") exit sub End If not exactly robust - but it worked for me -- jmoffa ----------------------------------------------------------------------- jmoffat's Profile: http://www.excelforum.com/member.php...nfo&userid=115 View this thread: http://www.excelforum.com/showthread.php?threadid=48093 |
Detecting if workbook running in IE or in Excel
I also experienced problems when running in the web. As a crude workaround I incorporated If (InStr(1, fname, "//") < 0) Then msgbox(" This workbook is not configured to run via the web") exit sub End If not exactly robust - but it worked for me -- jmoffa ----------------------------------------------------------------------- jmoffat's Profile: http://www.excelforum.com/member.php...nfo&userid=115 View this thread: http://www.excelforum.com/showthread.php?threadid=48093 |
Detecting if workbook running in IE or in Excel
Thanks to both Jim and jmoffat,
I realised that I did not share the knowledge I gained - apologies! Do not know whether this is the best way of doing things, but it works! 1) Create a new module called Module1. Put the following code in: Public geContainerType As ContainerTypes Enum ContainerTypes RunningInExcel RunningInIE RunningInUnknownApp End Enum Public Sub initiateContainerTest() Call Application.OnTime(Now + TimeSerial(0, 0, 7), "CheckContainer") End Sub In Activate (*not* workbook_open), called initiateContainerText() In Module1, add: Public Sub CheckContainer() Select Case ExcelOrIE Case RunningInExcel MsgBox "Running in Excel" Case RunningInIE, RunningInUnknownApp MsgBox "Running in IE" End Select End Sub Public Function ExcelOrIE() As ContainerTypes Dim lsContainerName As String On Error GoTo IsExcel lsContainerName = ThisWorkbook.Container.Name If lsContainerName = "Microsoft Internet Explorer" Then geContainerType = RunningInIE Else geContainerType = RunningInUnknownApp End If ExcelOrIE = geContainerType Exit Function IsExcel: ExcelOrIE = RunningInExcel End Function If you do not put the delay in OnTime, then it seems to think it is running in Excel, when in actual fact it is running in IE - go figure - any idea. All I know is put the initiateContainerText in workbook.activate and it works -reliably Cheers. |
All times are GMT +1. The time now is 10:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com