Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.dotnet.scripting,microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.dotnet.scripting,microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel in office 2007 fails to start.. HELP pls Arif[_2_] Setting up and Configuration of Excel 1 June 17th 08 09:50 AM
Excel fails on Save/Save As DanG[_2_] Excel Discussion (Misc queries) 11 May 16th 08 02:36 PM
Excel fails to save ChrisH Excel Discussion (Misc queries) 3 January 6th 06 01:30 PM
Excel fails to save properly Rolls Excel Discussion (Misc queries) 1 April 22nd 05 07:00 PM
Save As - Multiple Sheets fails to save as text file Ravee Srinivasan Excel Programming 2 November 10th 03 04:05 PM


All times are GMT +1. The time now is 03:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"