Code errors in Excel 2002

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
 
S

Simon Murphy

should that be
Activeworkbook.SaveAs Filename:=Filesavename ...?

not activesheet

you might try cstr(filesavename) too.

cheers
Simon
-----Original Message-----
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 _
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top