If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > A macro code to check whether any workbook is currently open or not.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-11-10, 07:29
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
A macro code to check whether any workbook is currently open or not.

Hi All,

I have created some toolbars for essbase connection. I won't a macro which will check whether there is any workbook which currently open or not. If there is no workbook open then macro should have code line which will show a message to the user that there is no workbook currently open and he can't run a macro. I have got a macro which check whether a particular workbook is open or not but it becomes specific because i will have to mention the name of the workbook. I want a macro code which will check whether any workbook is open or not. Please expedite. Thanks a lot for your help in advance.
Reply With Quote
  #2 (permalink)  
Old 04-11-10, 09:15
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hi,

I think the first thing I would try is:
Code:
    If ActiveWorkbook Is Nothing Then
 
        MsgBox "No workbook currently active"
 
    End If
I suggest this rather than checking Workbooks.Count in case a user has Personal.xls

Have a play around with it to see if there are any caveats?

Hope that helps...
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #3 (permalink)  
Old 04-11-10, 09:21
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
A macro code to check whether any workbook is currently open or not.

Thanks a lot. It's working now.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On