View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
external usenet poster
 
Posts: 1,163
Default How to Capture if Spreadsheet is open in IE and not Excel

There was a similar post not long ago: The solution is to check the Container
property of the workbook, which "Returns the object that contains the
specified embedded workbook." If the workbook is open in IE then
ThisWorkbook.Container.Name will be "Microsoft Internet Explorer." If it is
open in Excel, there is no "container" since it is not embedded, and the
property call will error out, so you need error trapping to catch that:

Public Function ExcelOrIE() As String
Dim CName as String

On Error Goto MustBeExcel
CName = ThisWorkbook.Container.Name

If CName = "Microsoft Internet Explorer" Then CName = "IE" Else CName =
"Something Else"

ExcelOrIE = CName
Exit Function

MustBeExcel:
ExcelorIE = "Excel"

End Function

"UBER_GEEK" wrote:

Constantly i find people are opening my forms which contain programming
in IE. Unfortunetly some code will not perform correctly in Ie, and
instead of figuring out what dosnt, It would be very convenient if
there were a way to tell if the spreadsheet's in ie or excel. Anyone
got any idea's?

Thanks