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

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Check for open workbooks

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.
Tel: 01509 223007 Fax: 01509 223940

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

"Stephen C" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Check for open workbooks

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.
Tel: 01509 223007 Fax: 01509 223940

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

"Stephen C" wrote in message
...
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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Check for open workbooks

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" wrote in message
...
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
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 Any workbooks are open Kevin R Excel Programming 3 September 13th 06 07:55 PM
Check if several workbooks are open Ricardo Silva Excel Programming 2 February 23rd 06 09:49 PM
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 04:05 AM.

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"