Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.dotnet.scripting,microsoft.public.excel.programming
|
|||
|
|||
XLBook.Save fails in Excel 2007
I have several vb scripts that copy data from csv files to xls files and the
XLBook.Save method worked fine in previous versions of Office. However, in Excel 2007 I get a "Save method of Workbook class failed" error when attempting to execute the following: Dim XL, CSVBook, XLBook Set XL = CreateObject("Excel.application") Set CSVBook = XL.Workbooks.Open("CSVfile.csv") Set XLBook = XL.Workbooks.Open("XLSfile.xls") CSVBook.Worksheets(1).Range("A1:C100").Copy XLBook.Worksheets("data").Select XLBook.Worksheets("data").Range("A1").PasteSpecial XLBook.Worksheets("data").Range("E1").Select CSVBook.Worksheets(1).Range("D1").ClearContents CSVBook.Close False XLBook.Save ****ERROR HAPPENS ON THIS LINE**** XL.Visible = True Does anyone know if the syntax has changed or if Excel 2007 uses a different method? |
#2
Posted to microsoft.public.dotnet.scripting,microsoft.public.excel.programming
|
|||
|
|||
XLBook.Save fails in Excel 2007
I got it working and here's the solution if anyone is interested:
My source xls file ("XLSfile.xls") was created in Excell 2003 so this was a simple version compatibility issue. To fix, open the xls file with Excel 2007 and save it. Then run the vbs file again - the XLBook.Save method should work fine now. "D.P. Roberts" wrote in message ... I have several vb scripts that copy data from csv files to xls files and the XLBook.Save method worked fine in previous versions of Office. However, in Excel 2007 I get a "Save method of Workbook class failed" error when attempting to execute the following: Dim XL, CSVBook, XLBook Set XL = CreateObject("Excel.application") Set CSVBook = XL.Workbooks.Open("CSVfile.csv") Set XLBook = XL.Workbooks.Open("XLSfile.xls") CSVBook.Worksheets(1).Range("A1:C100").Copy XLBook.Worksheets("data").Select XLBook.Worksheets("data").Range("A1").PasteSpecial XLBook.Worksheets("data").Range("E1").Select CSVBook.Worksheets(1).Range("D1").ClearContents CSVBook.Close False XLBook.Save ****ERROR HAPPENS ON THIS LINE**** XL.Visible = True Does anyone know if the syntax has changed or if Excel 2007 uses a different method? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel in office 2007 fails to start.. HELP pls | Setting up and Configuration of Excel | |||
Excel fails on Save/Save As | Excel Discussion (Misc queries) | |||
Excel fails to save | Excel Discussion (Misc queries) | |||
Excel fails to save properly | Excel Discussion (Misc queries) | |||
Save As - Multiple Sheets fails to save as text file | Excel Programming |