Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Check if Any workbooks are open

How do I check to see if ANY workbooks are open before running a macro? I
know how to check to see a particular workbook is open but I just want to
check to see if a (no specific) workbook is open before continuing the macro,
otherwise display a message if no workbook is open.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Check if Any workbooks are open

There must be at least one workbook open, the one with the code.

If Application.Workbooks.Count 1 Then
...

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Kevin R" wrote in message
...
How do I check to see if ANY workbooks are open before running a macro? I
know how to check to see a particular workbook is open but I just want to
check to see if a (no specific) workbook is open before continuing the

macro,
otherwise display a message if no workbook is open.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Check if Any workbooks are open

You can count the number of open workbooks
MsgBox Application.Workbooks.Count
Note that personal.xls is a workbook which (if it exists) is hidden. You did
not specify how you wanted to handle that (if at all) so I will leave that up
to you...
--
HTH...

Jim Thomlinson


"Kevin R" wrote:

How do I check to see if ANY workbooks are open before running a macro? I
know how to check to see a particular workbook is open but I just want to
check to see if a (no specific) workbook is open before continuing the macro,
otherwise display a message if no workbook is open.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Check if Any workbooks are open

Maybe you can just check for an active workbook?

Option Explicit
Sub testme()
If ActiveWorkbook Is Nothing Then
MsgBox "no visible workbook"
Else
MsgBox ActiveWorkbook.Name & " is active!"
End If
End Sub



Kevin R wrote:

How do I check to see if ANY workbooks are open before running a macro? I
know how to check to see a particular workbook is open but I just want to
check to see if a (no specific) workbook is open before continuing the macro,
otherwise display a message if no workbook is open.


--

Dave Peterson
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
Check if several workbooks are open Ricardo Silva Excel Programming 2 February 23rd 06 09:49 PM
When I open Excel, workbooks open automatically. How can I stop t Rhealbird Excel Discussion (Misc queries) 2 February 23rd 06 10:08 AM
workbooks.open function fails to open an existing excel file when used in ASP, but works in VB. san Excel Programming 1 January 3rd 06 03:22 AM
Check for open workbooks Steve Price Excel Programming 5 December 3rd 04 03:10 PM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM


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