A
Aidy
I am trying to read the name of the sheets of WorkBook B, from
WorkBook's A VBE. This is the code
<snip>
Dim oExcel As New Excel.Application
Dim oWorkBook As Workbook
Dim oWorkSheet As Worksheet
Sub OpenWorkBook(sFileName As String)
Set oWorkBook = oExcel.Workbooks.Open(Filename:=sFileName)
End Sub
Sub RetrieveWorkSheets()
Dim sName As String
For Each oWorkSheet In oWorkBook.Worksheets
sName = oWorkSheet.Name
Next oWorkSheet
End Sub
<snip>
However the name of the sheets in the WorkSheets collection is of the
Active Workbook and not the WorkBook I have opened in the OpenWorkBook
procedure.
Is there anyway to retrieve the sheet names from another workbook?
Cheers
Aidy
WorkBook's A VBE. This is the code
<snip>
Dim oExcel As New Excel.Application
Dim oWorkBook As Workbook
Dim oWorkSheet As Worksheet
Sub OpenWorkBook(sFileName As String)
Set oWorkBook = oExcel.Workbooks.Open(Filename:=sFileName)
End Sub
Sub RetrieveWorkSheets()
Dim sName As String
For Each oWorkSheet In oWorkBook.Worksheets
sName = oWorkSheet.Name
Next oWorkSheet
End Sub
<snip>
However the name of the sheets in the WorkSheets collection is of the
Active Workbook and not the WorkBook I have opened in the OpenWorkBook
procedure.
Is there anyway to retrieve the sheet names from another workbook?
Cheers
Aidy