Access9001
Registered User.
- Local time
- Today, 15:32
- Joined
- Feb 18, 2010
- Messages
- 268
All I can find is code explaining how to copy active sheets to other books, but that's not what I want. I want to open an Excel file and have it extract a sheet from another workbook and add it in. Possible?
I have this code on my workbook open event
Private Sub Workbook_Open()
If WorksheetExists("Summary") = False Then
Dim ObjXL As Excel.Application
Dim ObjXLBook As Excel.Workbook
Dim ObjXLSheet As Excel.Worksheet
Set ObjXL = CreateObject("Excel.Application")
Set ObjXLBook = ObjXL.Workbooks.Open(path to my workbook where the desired page is)
Set ObjXLSheet = ObjXLBook.Worksheets("Summary")
ObjXLBook.Activate
ObjXL.Sheets("Summary").Move before:= Workbooks(ThisWorkbook.FullName).Worksheets(1)
Set ObjXLSheet = Nothing
Set ObjXLBook = Nothing
ObjXL.Quit
Set ObjXL = Nothing
End If
End Sub
But it gives me a subscript out of range error
I have this code on my workbook open event
Private Sub Workbook_Open()
If WorksheetExists("Summary") = False Then
Dim ObjXL As Excel.Application
Dim ObjXLBook As Excel.Workbook
Dim ObjXLSheet As Excel.Worksheet
Set ObjXL = CreateObject("Excel.Application")
Set ObjXLBook = ObjXL.Workbooks.Open(path to my workbook where the desired page is)
Set ObjXLSheet = ObjXLBook.Worksheets("Summary")
ObjXLBook.Activate
ObjXL.Sheets("Summary").Move before:= Workbooks(ThisWorkbook.FullName).Worksheets(1)
Set ObjXLSheet = Nothing
Set ObjXLBook = Nothing
ObjXL.Quit
Set ObjXL = Nothing
End If
End Sub
But it gives me a subscript out of range error
Last edited: