ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clarification on "Application.Worbooks.Count" proceedure (https://www.excelbanter.com/excel-programming/344436-clarification-application-worbooks-count-proceedure.html)

Les Stout[_2_]

Clarification on "Application.Worbooks.Count" proceedure
 
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

*** Sent via Developersdex http://www.developersdex.com ***

[email protected]

Clarification on "Application.Worbooks.Count" proceedure
 
Hi
Works ok for me and gives a count of 4. Do you have more than one
instance of Excel open?

regards
Paul


Les Stout[_2_]

Clarification on "Application.Worbooks.Count" proceedure
 
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

*** Sent via Developersdex http://www.developersdex.com ***

Tom Ogilvy

Clarification on "Application.Worbooks.Count" proceedure
 
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.

--
Regards,
Tom Ogilvy


"Les Stout" wrote in message
...
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

*** Sent via Developersdex http://www.developersdex.com ***




Les Stout[_2_]

Clarification on "Application.Worbooks.Count" proceedure
 
Thanks Tom, but what is confusing me is that with just my workbook open
i still get a a count of two ?


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

[email protected]

Clarification on "Application.Worbooks.Count" proceedure
 
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


Les Stout[_2_]

Clarification on "Application.Worbooks.Count" proceedure
 
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

*** Sent via Developersdex http://www.developersdex.com ***

Tom Ogilvy

Clarification on "Application.Worbooks.Count" proceedure
 
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

--
Regards,
Tom Ogilvy


"Les Stout" wrote in message
...
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

*** Sent via Developersdex http://www.developersdex.com ***




Les Stout[_2_]

Clarification on "Application.Worbooks.Count" proceedure
 
At last.... Thanks Tom you are my lifesaver !!

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 09:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com