Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Warning if other files open

Need a "warning" MsgBox, saying that another Excel file is open and do I wish
to close it before proceeding, and if yes then close without saving.
In other words, if ActiveWindow.ActivateNext goes anywhere other than the
current file, that warning should pop up.

Thanx,
- Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Warning if other files open

Would Workbooks.Count give you what you are looking for? Be careful though,
as it counts the Personal.xls, if it exists, as being open. Perhaps this
line will do what you want...

WBcount = Workbooks.Count + (Len(Workbooks("Personal.xls").Name) 0)

where if WBcount is greater than 1 then another workbook is open in that
session of Excel (if you have a second session of Excel open, this code will
not see it). Oh, and yes, the + sign in the above code line is correct
because the logical expression evaluates to -1 if true.

--
Rick (MVP - Excel)


"MikeF" wrote in message
...
Need a "warning" MsgBox, saying that another Excel file is open and do I
wish
to close it before proceeding, and if yes then close without saving.
In other words, if ActiveWindow.ActivateNext goes anywhere other than the
current file, that warning should pop up.

Thanx,
- Mike


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Warning if other files open

Sub mikef()
n = Workbooks.Count
If n 1 Then
MsgBox ("WARNING!!!" & Chr(10) & "There are " & n & " workbooks open!!")
End If
End Sub

--
Gary''s Student - gsnu200824


"MikeF" wrote:

Need a "warning" MsgBox, saying that another Excel file is open and do I wish
to close it before proceeding, and if yes then close without saving.
In other words, if ActiveWindow.ActivateNext goes anywhere other than the
current file, that warning should pop up.

Thanx,
- Mike

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Warning if other files open

Thanx.

"Rick Rothstein" wrote:

Would Workbooks.Count give you what you are looking for? Be careful though,
as it counts the Personal.xls, if it exists, as being open. Perhaps this
line will do what you want...

WBcount = Workbooks.Count + (Len(Workbooks("Personal.xls").Name) 0)

where if WBcount is greater than 1 then another workbook is open in that
session of Excel (if you have a second session of Excel open, this code will
not see it). Oh, and yes, the + sign in the above code line is correct
because the logical expression evaluates to -1 if true.

--
Rick (MVP - Excel)


"MikeF" wrote in message
...
Need a "warning" MsgBox, saying that another Excel file is open and do I
wish
to close it before proceeding, and if yes then close without saving.
In other words, if ActiveWindow.ActivateNext goes anywhere other than the
current file, that warning should pop up.

Thanx,
- Mike



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Warning if other files open


Thanx.

"MikeF" wrote:

Need a "warning" MsgBox, saying that another Excel file is open and do I wish
to close it before proceeding, and if yes then close without saving.
In other words, if ActiveWindow.ActivateNext goes anywhere other than the
current file, that warning should pop up.

Thanx,
- Mike



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Warning if other files open

Thanx.

"Gary''s Student" wrote:

Sub mikef()
n = Workbooks.Count
If n 1 Then
MsgBox ("WARNING!!!" & Chr(10) & "There are " & n & " workbooks open!!")
End If
End Sub

--
Gary''s Student - gsnu200824


"MikeF" wrote:

Need a "warning" MsgBox, saying that another Excel file is open and do I wish
to close it before proceeding, and if yes then close without saving.
In other words, if ActiveWindow.ActivateNext goes anywhere other than the
current file, that warning should pop up.

Thanx,
- Mike

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
Getting Warning when I try to open ecxel in 2007. Vidya Excel Discussion (Misc queries) 0 November 28th 08 09:46 AM
Number add-in warning comes up when opening files m_ridzon Excel Discussion (Misc queries) 1 March 15th 07 05:12 PM
Warning before saving files! [email protected] Excel Discussion (Misc queries) 4 January 17th 07 12:26 AM
Excel file already open warning binaryben Setting up and Configuration of Excel 0 July 6th 05 12:30 PM
Playing .wav files (why do a few cause warning messages?) Cybert Excel Programming 0 October 19th 04 09:38 PM


All times are GMT +1. The time now is 03:42 PM.

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

About Us

"It's about Microsoft Excel"