G
Guest
Hi, The code below works OK using Excel 2000 but Gives run time error code
1004
Application-defined or object-defined error when running in Excel 2002
(Office XP)
Please can anyone help as I,ve tried all options I can think of.
I am trying to copy the format & values from a range in one workbook, open a
new
and save this new with a filename selected by the user
code:=
Range("A2:M73").Select
Selection.Copy
Workbooks.Add
Range("A2").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,SkipBlanks:=False _
, Transpose:=False Selection.PasteSpecial Paste:=xlFormats,
Operation:=xlNone,_ SkipBlanks:=False _
, Transpose:=False
Application.CutCopyMode = False
Filesavename = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls")
If Filesavename <> False Then
(the code below this gives the error)
ActiveSheet.SaveAs Filename:=Filesavename,_
FileFormat:=xlNormal,Password:="", WriteResPassword:="",_
ReadOnlyRecommended:=False , CreateBackup:=False
End If
ActiveWorkbook.Close SaveChanges:=False
ActiveWorkbook.Close SaveChanges:=False
End Sub
1004
Application-defined or object-defined error when running in Excel 2002
(Office XP)
Please can anyone help as I,ve tried all options I can think of.
I am trying to copy the format & values from a range in one workbook, open a
new
and save this new with a filename selected by the user
code:=
Range("A2:M73").Select
Selection.Copy
Workbooks.Add
Range("A2").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,SkipBlanks:=False _
, Transpose:=False Selection.PasteSpecial Paste:=xlFormats,
Operation:=xlNone,_ SkipBlanks:=False _
, Transpose:=False
Application.CutCopyMode = False
Filesavename = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls")
If Filesavename <> False Then
(the code below this gives the error)
ActiveSheet.SaveAs Filename:=Filesavename,_
FileFormat:=xlNormal,Password:="", WriteResPassword:="",_
ReadOnlyRecommended:=False , CreateBackup:=False
End If
ActiveWorkbook.Close SaveChanges:=False
ActiveWorkbook.Close SaveChanges:=False
End Sub