Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel SaveAs Truncates HELP

Status
Not open for further replies.
Jul 22, 2002
25
US
I have a workbook containing worksheets. I am saving one of these worksheets. When I do it, Excel truncates the cell contents to 255 characters. I looked into it, and it seems like my "ActiveSheet.Copy" line is the problem. I do NOT want to simply "rename" the file, whcih is what the SaveAs would do, so I "copy" the worksheet first, then save that. By doing this, it truncates any cell length to 255.

Here is the code I have:

'start
ThisWorkbook.Worksheets("Package").Activate
ActiveSheet.Copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="Junk.cps", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'end

Any ideas are greatly appreciated....

 
instead of doing:

activesheet.copy
activeworkbook.saveas .......

do:

activeworkbook.savecopyas

if you do not want to save all sheets. save your master copy, delete the sheets that you do not want then run the above

 
The behavior you're seeing is an oddity of Excel VBA. You can get around it by copying the sheet's CONTENTS instead of the sheet itself to a new sheet, e.g.
activesheet.usedrange.copy OtherWorkbook.sheets(1).range("A1")
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top