Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Test if spreadsheet id open in IE

Hi NG!

Is there a way to test if a spreadsheet is opened in native Excel or in
Excel showing in an Internet Explorer window?

Jan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Test if spreadsheet id open in IE

Jan,

I did a bit of puzzling, but following seems to work
in most cases. (When explorer is open, or when workbook is
open with "open with" Internet Explorer.

the structure of the windows, window parents and captions
is slightly different. However.. there's the IsInPlace property.

You must use the OnTime, as events are run first, before the window is
placed in the IEframe... so you have to build a delay..

Once the user has the window visible the delay is not needed.


'Thisworkbook..
Option Explicit

Dim bDone As Boolean

Private Sub Workbook_Activate()
If Not bDone Then
bDone = True
Call Application.OnTime(Now + TimeSerial(0, 0, 1), _
ThisWorkbook.Name & "!TimedMsg")
End If
End Sub

'Normal non private module
Option Explicit

Sub TimedMsg()
If ThisWorkbook.IsInPlace Then
MsgBox "Yep. I'm loaded in internet Explorer"
endif
End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Jan Kronsell wrote :

Hi NG!

Is there a way to test if a spreadsheet is opened in native Excel or
in Excel showing in an Internet Explorer window?

Jan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Test if spreadsheet id open in IE

If ThisWorkbook.IsInPlace Then

I think this would confirm the file is not opened in Excel but as an object
in some other app, that might but not necessarily be IE ?

Regards,
Peter T

"keepITcool" wrote in message
.com...
Jan,

I did a bit of puzzling, but following seems to work
in most cases. (When explorer is open, or when workbook is
open with "open with" Internet Explorer.

the structure of the windows, window parents and captions
is slightly different. However.. there's the IsInPlace property.

You must use the OnTime, as events are run first, before the window is
placed in the IEframe... so you have to build a delay..

Once the user has the window visible the delay is not needed.


'Thisworkbook..
Option Explicit

Dim bDone As Boolean

Private Sub Workbook_Activate()
If Not bDone Then
bDone = True
Call Application.OnTime(Now + TimeSerial(0, 0, 1), _
ThisWorkbook.Name & "!TimedMsg")
End If
End Sub

'Normal non private module
Option Explicit

Sub TimedMsg()
If ThisWorkbook.IsInPlace Then
MsgBox "Yep. I'm loaded in internet Explorer"
endif
End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Jan Kronsell wrote :

Hi NG!

Is there a way to test if a spreadsheet is opened in native Excel or
in Excel showing in an Internet Explorer window?

Jan



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Test if spreadsheet id open in IE

Hi

I give a shot, then get back to you.

Jan


"keepITcool" wrote in message
.com...
Jan,

I did a bit of puzzling, but following seems to work
in most cases. (When explorer is open, or when workbook is
open with "open with" Internet Explorer.

the structure of the windows, window parents and captions
is slightly different. However.. there's the IsInPlace property.

You must use the OnTime, as events are run first, before the window is
placed in the IEframe... so you have to build a delay..

Once the user has the window visible the delay is not needed.


'Thisworkbook..
Option Explicit

Dim bDone As Boolean

Private Sub Workbook_Activate()
If Not bDone Then
bDone = True
Call Application.OnTime(Now + TimeSerial(0, 0, 1), _
ThisWorkbook.Name & "!TimedMsg")
End If
End Sub

'Normal non private module
Option Explicit

Sub TimedMsg()
If ThisWorkbook.IsInPlace Then
MsgBox "Yep. I'm loaded in internet Explorer"
endif
End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Jan Kronsell wrote :

Hi NG!

Is there a way to test if a spreadsheet is opened in native Excel or
in Excel showing in an Internet Explorer window?

Jan



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Test if spreadsheet id open in IE

A better method is to use the Container property of the workbook. This gives
and Object reference to the containing object IF the book is open as an
embedded object (e.g. in IE). It fails (errors) if Excel is open as a
standalone app, so that needs to be determined with some error handling.

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

"Jan Kronsell" wrote:

Hi NG!

Is there a way to test if a spreadsheet is opened in native Excel or in
Excel showing in an Internet Explorer window?

Jan





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Test if spreadsheet id open in IE

Thnx.

I agree container gives more info then IsInPlace.
thnx for the tip.

See my original post for delaying any event macro's until loading is
complete before calling on the container.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


K Dales wrote :

A better method is to use the Container property of the workbook.
This gives and Object reference to the containing object IF the book
is open as an embedded object (e.g. in IE). It fails (errors) if
Excel is open as a standalone app, so that needs to be determined
with some error handling.

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

"Jan Kronsell" wrote:

Hi NG!

Is there a way to test if a spreadsheet is opened in native Excel
or in Excel showing in an Internet Explorer window?

Jan



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
Test to see if a workbook is open Brettjg Excel Discussion (Misc queries) 1 March 5th 07 09:26 AM
Test for Open File Aaron Excel Programming 6 January 6th 05 12:37 PM
Test if a workbook is open already Kieran1028[_17_] Excel Programming 7 November 22nd 04 08:13 PM
Test that a workbook is open Gef[_2_] Excel Programming 2 April 6th 04 11:17 AM
Test to see if a spreadsheet window is open lopsided[_6_] Excel Programming 2 December 17th 03 10:42 AM


All times are GMT +1. The time now is 02:30 PM.

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"