ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Warning if other files open (https://www.excelbanter.com/excel-programming/422108-warning-if-other-files-open.html)

MikeF[_2_]

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

Rick Rothstein

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



Gary''s Student

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


MikeF[_2_]

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




MikeF[_2_]

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


MikeF[_2_]

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



All times are GMT +1. The time now is 09:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com