Clarification on "Application.Worbooks.Count" proceedure

L

Les Stout

Hi all, i use the code below to count the workbooks open.
My problem, i have my workbook "Recon_Tools.xls" open and Book1, Book2 &
book3 but it shows me a count of "2" ?? I believe it should show me a
count of "4" ?? Any help would be appreciated.

Sub testing1()
'
Dim wkb As Integer
wkb = Application.Workbooks.Count
If wkb = 2 Then
Application.Quit
Else
Unload SelectionForm
ActiveWorkbook.Close
Workbooks("Recon_Tool.xls").Close
End If
End Sub


Les Stout
 
P

paul.robinson

Hi
Works ok for me and gives a count of 4. Do you have more than one
instance of Excel open?

regards
Paul
 
L

Les Stout

Hi Paul, i have my workbook with script open and then i open excel again
giving me "Microsft Excel - Book1" and "Microsft Excel - Book2"2 as
well.
But i still only get a figure of 2 ?

Les Stout
 
T

Tom Ogilvy

The two separate instances of excel are just that - separate programs and
have no relationship to each other. Each is a separate application with its
own workbooks.count.
 
L

Les Stout

Thanks Tom, but what is confusing me is that with just my workbook open
i still get a a count of two ?


Les Stout
 
P

paul.robinson

Hi
Does your excel open with a blank workbook by default? You might not
spot it is open with the "helpful" Window intelli-menu

Paul
 
L

Les Stout

Hi Paul, i cannot see another workbook or does it see the personal as a
workbook as well ? Sorry bit of a newbie at this game and not sure what
the "helpful" window intelli-menu is ??

Les Stout
 
T

Tom Ogilvy

Do you have a personal macro workbook that is hidden?

Just write a macro an clear up the mystery

sub showbooks()
for each bk in Workbooks
msgbox bk.name
Next
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top