PC Review


Reply
Thread Tools Rate Thread

Check for open workbooks

 
 
=?Utf-8?B?U3RlcGhlbiBD?=
Guest
Posts: n/a
 
      24th Oct 2006
How do i check to find out if any other workbooks are open?

I need to do this check in a macro therefore require the VBA code.

I have a workbook with a macro in, when a user runs this macro i need it to
check to see if any other workbooks are open. This macro will not run
correctly if others are open.

I am using Office 2000 - SP3


 
Reply With Quote
 
 
 
 
Adrian D. Bailey
Guest
Posts: n/a
 
      24th Oct 2006
function bookcount()
bookcount=workbooks.count
end function

For your macro to work, you need bookcount to be 1
--
Adrian D.Bailey, Information and Systems Manager, Dept.Human Sciences
Loughborough University, Loughborough Leics, LE11 3TU, UK.
(E-Mail Removed) Tel: 01509 223007 Fax: 01509 223940

Community Warden, Storer and Burleigh Areas. Out-of-hours Tel: 01509 563263
--

"Stephen C" <(E-Mail Removed)> wrote in message
news:2821DF4B-D201-4413-9074-(E-Mail Removed)...
> How do i check to find out if any other workbooks are open?
>
> I need to do this check in a macro therefore require the VBA code.
>
> I have a workbook with a macro in, when a user runs this macro i need it
> to
> check to see if any other workbooks are open. This macro will not run
> correctly if others are open.
>
> I am using Office 2000 - SP3
>
>



 
Reply With Quote
 
Mike Fogleman
Guest
Posts: n/a
 
      24th Oct 2006
You will need to trap for the Personal.xls workbook which will always be
open if the user has one.

Sub CountWBOpen()
Dim wb As Workbook
Dim x As Integer

x = Workbooks.Count
For Each wb In Workbooks
If wb.name = "Personal.xls" Then
x = x - 1
End If
Next
If x > 1 Then
MsgBox ("more than 1")
Exit Sub
Else
MsgBox ("only 1")
End If
End Sub

Mike F
"Stephen C" <(E-Mail Removed)> wrote in message
news:2821DF4B-D201-4413-9074-(E-Mail Removed)...
> How do i check to find out if any other workbooks are open?
>
> I need to do this check in a macro therefore require the VBA code.
>
> I have a workbook with a macro in, when a user runs this macro i need it
> to
> check to see if any other workbooks are open. This macro will not run
> correctly if others are open.
>
> I am using Office 2000 - SP3
>
>



 
Reply With Quote
 
=?Utf-8?B?U3RlcGhlbiBD?=
Guest
Posts: n/a
 
      24th Oct 2006
Thanks, Just what i was after, A simple short piece of code.

"Adrian D. Bailey" wrote:

> function bookcount()
> bookcount=workbooks.count
> end function
>
> For your macro to work, you need bookcount to be 1
> --
> Adrian D.Bailey, Information and Systems Manager, Dept.Human Sciences
> Loughborough University, Loughborough Leics, LE11 3TU, UK.
> (E-Mail Removed) Tel: 01509 223007 Fax: 01509 223940
>
> Community Warden, Storer and Burleigh Areas. Out-of-hours Tel: 01509 563263
> --
>
> "Stephen C" <(E-Mail Removed)> wrote in message
> news:2821DF4B-D201-4413-9074-(E-Mail Removed)...
> > How do i check to find out if any other workbooks are open?
> >
> > I need to do this check in a macro therefore require the VBA code.
> >
> > I have a workbook with a macro in, when a user runs this macro i need it
> > to
> > check to see if any other workbooks are open. This macro will not run
> > correctly if others are open.
> >
> > I am using Office 2000 - SP3
> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop Check for Workbooks already open u473 Microsoft Excel Programming 2 3rd Dec 2008 10:28 PM
Function Call to check Workbooks.Open RompStar Microsoft Excel Programming 5 12th May 2008 11:21 PM
Check if Any workbooks are open =?Utf-8?B?S2V2aW4gUg==?= Microsoft Excel Programming 3 13th Sep 2006 07:55 PM
Check if several workbooks are open =?Utf-8?B?UmljYXJkbyBTaWx2YQ==?= Microsoft Excel Programming 2 23rd Feb 2006 09:49 PM
Check for open workbooks =?Utf-8?B?U3RldmUgUHJpY2U=?= Microsoft Excel Programming 5 3rd Dec 2004 03:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:39 AM.