Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import sheet error
Hi
I am trying to use the below code to import a title page for my reports but it is coming with the error message: 'Compile error: Object error' On line 'Set CurrWb = ActiveWorkbook.Name' Can anyone help resolve this? TIA Sub AddTitlePage() Dim CurrWb As String Dim TitleWb As Workbook Set CurrWb = ActiveWorkbook.Name Set TitleWb = Workbooks.Open("F:\Resources\Title Page.xls") With TitleWb ..Sheets("Title").Copy Befo=Workbooks(CurrWb).Sheets(1) ..Close End With End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Import sheet error
Edgar,
As a general rule, unless you are assigning an object, you don't need a Set statement. i.e. CurrWb = ActiveWorkbook.Name But, you could do the whole thing without the use of the String, e.g. Sub AddTitlePage() Dim CurrWb As WORKBOOK Dim TitleWb As Workbook Set CurrWb = ActiveWorkbook Set TitleWb = Workbooks.Open("F:\Resources\Title Page.xls") With TitleWb ..Sheets("Title").Copy Befo=CurrWb.Sheets(1) ..Close End With End Sub Robin Hammond www.enhanceddatasystems.com "Edgar Thoemmes" wrote in message ... Hi I am trying to use the below code to import a title page for my reports but it is coming with the error message: 'Compile error: Object error' On line 'Set CurrWb = ActiveWorkbook.Name' Can anyone help resolve this? TIA Sub AddTitlePage() Dim CurrWb As String Dim TitleWb As Workbook Set CurrWb = ActiveWorkbook.Name Set TitleWb = Workbooks.Open("F:\Resources\Title Page.xls") With TitleWb .Sheets("Title").Copy Befo=Workbooks(CurrWb).Sheets(1) .Close End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
XML Import Parsing error | Excel Discussion (Misc queries) | |||
Excel 2007 Japanese Import Error | Excel Discussion (Misc queries) | |||
MS Query import from Excel - Syntax Error | Excel Discussion (Misc queries) | |||
Error message when trying to import csv into Outlook contacts. | Excel Discussion (Misc queries) | |||
HTML/XML Import Error -ExcelName | Excel Programming |