Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Detecting a another workbook has opended

Hi All
In an Excel workbook is there a method to detect that the user has opended
or is opening another workbook ?

For instance......

A workbook application is open, the user navigates in explorer to another
xls file and double clicks it, this opens in the existing instance of xL, is
there a way for the already open workbook to detect this new workbook, with
the following actions....

1. Tell the user they must close the current application before loading a
new workbook
2. Prevent the new workbook from opening.


--
Cheers
Nigel




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Detecting a another workbook has opended

In reply to my own request I have come up with the following approach, but
not sure if it is foolproof? Perhaps someone might comment on it?

Option Explicit
Public wbOpen As Boolean

Private Sub Workbook_Deactivate()
If Workbooks.Count 1 And wbOpen Then
MsgBox "You must close MyApplication before opening another workbook"
'close the rogue book
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End If
End Sub

Private Sub Workbook_Open()
wbOpen = True
If Workbooks.Count 1 Then
MsgBox "OPEN - You must close the current Excel workooks before opening
MyApplication"
wbOpen = False
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End If
End Sub


--
Cheers
Nigel



"Nigel" wrote in message
...
Hi All
In an Excel workbook is there a method to detect that the user has opended
or is opening another workbook ?

For instance......

A workbook application is open, the user navigates in explorer to another
xls file and double clicks it, this opens in the existing instance of xL,

is
there a way for the already open workbook to detect this new workbook,

with
the following actions....

1. Tell the user they must close the current application before loading a
new workbook
2. Prevent the new workbook from opening.


--
Cheers
Nigel






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
Not detecting Open Workbook - Why Roger Excel Discussion (Misc queries) 7 January 26th 08 08:16 PM
Not Detecting Open Workbook Status - Odd?? Jenny B. Excel Discussion (Misc queries) 4 January 16th 08 12:47 AM
Detecting if a Window/Workbook is Open Rob Excel Discussion (Misc queries) 5 July 10th 07 10:52 PM
Detecting Mac Plataform jose luis Excel Programming 1 September 5th 04 06:20 AM
Detecting workbook activation Jack Wolf Excel Programming 0 July 26th 03 01:10 AM


All times are GMT +1. The time now is 11:25 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"