aziz rasul
01-16-2008, 03:32 AM
I have the following snippet of code:-
Dim objExcelApp As Object
Set objExcelApp = CreateObject("Excel.Application")
With objExcelApp
.Workbooks.Open FileName:=strExcelFile
.Visible = True
lngRow = ws.UsedRange.Rows.Count
.Range("A2:BU" & lngRow).Select
.Selection.Copy
.Workbooks.Open FileName:="\\stg1nas02\theatred\Aziz\Theatre Reports\Theatre Utilisation Report Template.xls"
.Range("A2:BU2").Select
.Windows("Theatre Utilisation Report Template.xls").Activate
.Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
etc.
I get a run-time error 1004 i.e. Pastespecial Method Of Range Class Failed
What am I doing wrong?
Dim objExcelApp As Object
Set objExcelApp = CreateObject("Excel.Application")
With objExcelApp
.Workbooks.Open FileName:=strExcelFile
.Visible = True
lngRow = ws.UsedRange.Rows.Count
.Range("A2:BU" & lngRow).Select
.Selection.Copy
.Workbooks.Open FileName:="\\stg1nas02\theatred\Aziz\Theatre Reports\Theatre Utilisation Report Template.xls"
.Range("A2:BU2").Select
.Windows("Theatre Utilisation Report Template.xls").Activate
.Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
etc.
I get a run-time error 1004 i.e. Pastespecial Method Of Range Class Failed
What am I doing wrong?