I can't see a Workbook in WorkBooks.Count

  • Thread starter Thread starter Jordi
  • Start date Start date
J

Jordi

I've two workbooks opened, but each one in one different Excel's windows,
how can I work with both by code?

The sentence:

?Workbooks.count

only returns one.
 
Jordi,

If Workbooks.Count returns 1, then you have only 1 workbook open, with
mutliple windows of that one workbook. Try using

Debug.Print ActiveWorkbook.Windows.Count

to confirm.

Then you really aren't working with different workbooks - just
different views of the same workbook.

HTH,
Bernie
MS Excel MVP
 
Thank you for your attention, but isn't the case.
I open one workbook, and then another aplications creates a new workbook, in
the Window menu I only see the current window in each Excel, but I have two
workbooks opened in two Excel.

I'm using Excel 2002.
 
Jordi,

Why are you using two instances rather than a single instance?

In your other application, you can find the current active Excel by
using GetObject:

Public xlApp As Excel.Application
On Error Resume Next
Set xlApp = GetObject("Excel.Application")
If xlApp = Nothing Then
Set xlApp = CreateObject("Excel.Application")
End If

You will need to have a reference set to the Excel object library in
your other application.

Then, you should be able to find all open workbooks, since you will
only have one Excel.

HTH,
Bernie
MS Excel MVP
 
Back
Top