Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Import Parsing error Jeff Excel Discussion (Misc queries) 1 October 10th 09 10:50 AM
Excel 2007 Japanese Import Error hamster0914 Excel Discussion (Misc queries) 0 December 29th 06 02:30 AM
MS Query import from Excel - Syntax Error EstherJ Excel Discussion (Misc queries) 1 April 24th 06 09:44 AM
Error message when trying to import csv into Outlook contacts. [email protected] Excel Discussion (Misc queries) 1 April 13th 06 03:15 PM
HTML/XML Import Error -ExcelName smcclure Excel Programming 0 October 22nd 04 06:19 AM


All times are GMT +1. The time now is 05:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"