I can't see a Workbook in WorkBooks.Count

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.
 
B

Bernie Deitrick

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
 
J

Jordi

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.
 
B

Bernie Deitrick

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
 

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