Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to tell if Excel is in Browser or Application

I have a website with a hyperlink to an Excel spreadsheet. Some computers
are setup so that Excel opens in a browser, others open in the Excel
application. I need to know if Excel is in a browser or not - since most of
my macros don't work in a browser.

Is there code to know if this? It has to work with Excel 97 through 2003.
I'm thinking if there is something that errors out when in a browser, I could
catch that error and know that way.

Any insight is appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default How to tell if Excel is in Browser or Application

This is a routine posted by Ture Magnusson that may may give you some ideas:

Sub CheckIfInInternetExplorer()
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
End Sub

--
Jim Rech
Excel MVP
"Ken Valenti" <Ken wrote in message
...
|I have a website with a hyperlink to an Excel spreadsheet. Some computers
| are setup so that Excel opens in a browser, others open in the Excel
| application. I need to know if Excel is in a browser or not - since most
of
| my macros don't work in a browser.
|
| Is there code to know if this? It has to work with Excel 97 through 2003.
| I'm thinking if there is something that errors out when in a browser, I
could
| catch that error and know that way.
|
| Any insight is appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default How to tell if Excel is in Browser or Application

This would be perfect, but I can't get it to work in 97 or 2003.

If I take out on error resume next, it always errors out. Either in a
browser or application. Is there a reference I am missing?'

"Jim Rech" wrote:

This is a routine posted by Ture Magnusson that may may give you some ideas:

Sub CheckIfInInternetExplorer()
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
End Sub

--
Jim Rech
Excel MVP
"Ken Valenti" <Ken wrote in message
...
|I have a website with a hyperlink to an Excel spreadsheet. Some computers
| are setup so that Excel opens in a browser, others open in the Excel
| application. I need to know if Excel is in a browser or not - since most
of
| my macros don't work in a browser.
|
| Is there code to know if this? It has to work with Excel 97 through 2003.
| I'm thinking if there is something that errors out when in a browser, I
could
| catch that error and know that way.
|
| Any insight is appreciated.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel in web browser Zahi Savion Excel Programming 0 October 20th 04 06:10 PM
macro to close excel application other than application.quit mary Excel Programming 1 September 14th 04 03:43 PM
Application coding in Web Browser Craig[_18_] Excel Programming 0 June 24th 04 01:49 PM
Excel and web browser Marcin Kwa¶niewski Excel Programming 6 April 13th 04 11:36 AM
application.screenupdating problems and IE browser window belinda Excel Programming 0 September 17th 03 12:00 PM


All times are GMT +1. The time now is 01:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"