Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DKS DKS is offline
external usenet poster
 
Posts: 103
Default Determining the number of open workbooks

Hi,

How can I programatically (via module) determine the number of open
workbooks? Ideally I would love to also determine the names (titles) of each
open workbook, but if that is too much then I can at least live with the
retrieval of info on the number of open workbooks.

Many thanks in anticipation.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Determining the number of open workbooks

Number of workbooks is....

Workbooks.Count

Display each name in MsgBox.....

Dim wB As Workbook
For Each wB In Workbooks
MsgBox wB.Name
Next

--

Regards,
Nigel




"DKS" wrote in message
...
Hi,

How can I programatically (via module) determine the number of open
workbooks? Ideally I would love to also determine the names (titles) of
each
open workbook, but if that is too much then I can at least live with the
retrieval of info on the number of open workbooks.

Many thanks in anticipation.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Determining the number of open workbooks

Hi DKS

You can count the workbooks in the loop

Dim wb As Workbook
For Each wb In Application.Workbooks
MsgBox wb.Name
Next wb


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"DKS" wrote in message ...
Hi,

How can I programatically (via module) determine the number of open
workbooks? Ideally I would love to also determine the names (titles) of each
open workbook, but if that is too much then I can at least live with the
retrieval of info on the number of open workbooks.

Many thanks in anticipation.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Determining the number of open workbooks

Forgot to add this

Test if the workbooks are visible in the loop if that is important.
For example if you want to be sure that there is a visible workbook open

Personal.xls will count as 1 for example

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Ron de Bruin" wrote in message ...
Hi DKS

You can count the workbooks in the loop

Dim wb As Workbook
For Each wb In Application.Workbooks
MsgBox wb.Name
Next wb


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"DKS" wrote in message ...
Hi,

How can I programatically (via module) determine the number of open
workbooks? Ideally I would love to also determine the names (titles) of each
open workbook, but if that is too much then I can at least live with the
retrieval of info on the number of open workbooks.

Many thanks in anticipation.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Determining the number of open workbooks

Here is some code to try...

Sub test()
Dim wbk As Workbook

MsgBox Workbooks.Count
For Each wbk In Workbooks
MsgBox wbk.Name
Next wbk
End Sub

Note that this code will be correct if there is only one open instance of
XL. If you have multiple open instances then it only works on the instance
that it is in. That should not be a problem but it is something to be aware
of...
--
HTH...

Jim Thomlinson


"DKS" wrote:

Hi,

How can I programatically (via module) determine the number of open
workbooks? Ideally I would love to also determine the names (titles) of each
open workbook, but if that is too much then I can at least live with the
retrieval of info on the number of open workbooks.

Many thanks in anticipation.



  #6   Report Post  
Posted to microsoft.public.excel.programming
DKS DKS is offline
external usenet poster
 
Posts: 103
Default Determining the number of open workbooks

If we open several excel files, would it not be in the same instance of Excel
by default?



"Jim Thomlinson" wrote:

Here is some code to try...

Sub test()
Dim wbk As Workbook

MsgBox Workbooks.Count
For Each wbk In Workbooks
MsgBox wbk.Name
Next wbk
End Sub

Note that this code will be correct if there is only one open instance of
XL. If you have multiple open instances then it only works on the instance
that it is in. That should not be a problem but it is something to be aware
of...
--
HTH...

Jim Thomlinson


"DKS" wrote:

Hi,

How can I programatically (via module) determine the number of open
workbooks? Ideally I would love to also determine the names (titles) of each
open workbook, but if that is too much then I can at least live with the
retrieval of info on the number of open workbooks.

Many thanks in anticipation.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Determining the number of open workbooks

If you double click on an XL file then it opens in one instance of XL. If you
then choose file | Open or if you double click on another XL file it will be
opened in the same original instance. If you now click on Start | Programs
.... Excel then you get another instance of XL. Files opened in this instance
know nothing of the other instance and Vice Versa. If you look in Task
manager you will see 2 seperate XL processes running...
--
HTH...

Jim Thomlinson


"DKS" wrote:

If we open several excel files, would it not be in the same instance of Excel
by default?



"Jim Thomlinson" wrote:

Here is some code to try...

Sub test()
Dim wbk As Workbook

MsgBox Workbooks.Count
For Each wbk In Workbooks
MsgBox wbk.Name
Next wbk
End Sub

Note that this code will be correct if there is only one open instance of
XL. If you have multiple open instances then it only works on the instance
that it is in. That should not be a problem but it is something to be aware
of...
--
HTH...

Jim Thomlinson


"DKS" wrote:

Hi,

How can I programatically (via module) determine the number of open
workbooks? Ideally I would love to also determine the names (titles) of each
open workbook, but if that is too much then I can at least live with the
retrieval of info on the number of open workbooks.

Many thanks in anticipation.

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
How to tell the number of current open workbooks... [email protected] Excel Worksheet Functions 1 April 16th 07 04:06 PM
Determining repeated cells between two workbooks farful Excel Programming 1 July 8th 06 06:55 PM
Determining if Other Workbooks Are Open Chaplain Doug Excel Programming 6 May 16th 05 08:12 PM
count number of workbooks open Ronaldo Excel Programming 2 April 21st 05 01:00 PM
Number of workbooks open Tim U[_2_] Excel Programming 1 June 30th 04 06:03 PM


All times are GMT +1. The time now is 05:17 PM.

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"