View Full Version : PasteSpecial


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?

aziz rasul
01-16-2008, 06:23 AM
It's OK folks I obtained the solution, which was essentially

.ActiveSheet.Range("A2:BU2").PasteSpecial Paste:=12, Operation:=-4142, SkipBlanks:=False, Transpose:=False