View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Workbooks Index (Excel 97)

? thisworkbook.Windows(1).Index
2

or
ActiveWorkbook.windows(1).Index

Ran this
Sub CheckIndex()
For Each wkbk In Workbooks
Idex = wkbk.Windows(1).Index
i = 0
For Each wkbk1 In Workbooks
i = i + 1
If wkbk1.Name = wkbk.Name Then
idex1 = i
Exit For
End If
Next

Debug.Print Idex, idex1, _
Workbooks(Idex).Name, Workbooks(idex1).Name
Next

End Sub

and it clearly showed me there is no correlation between the Index of the
workbook collection and the index of the Windows collection, but you may be
able to meet your need by using the windows collection.

? activewindow.Index, activewindow.Parent.Name
1 check_proc.xls

Of course the activewindow is always going to be index 1. The parent of a
window is a workbook object.

--
Regards,
Tom Ogilvy



David Copp wrote in message
. ca...
Greetings,

Would like to be able to use "Index" for workbook collection but does not
appear to be able to do so.

'i.e. index works fine for sheet collections as in following
MsgBox ActiveWorkbook.ActiveSheet.Index

'but fails at workbook level.
MsgBox ActiveWorkbook.Index

Any help would be appreciated.

Thanks,

Dave