This really drove me crazy! The counterpart simlar code for docx<->doc and
pptx<->ppt just worked smoothly.
And I found a phenomenon (rather than workround) that the file will be
saved if an extra wasted line is added ahead the target 'SaveAs'
line. (see the commented code below).
Besides:
The wasted SaveAs doesn't really have function to save things(as the
original problem)
The target SaveAs doesn't work if the wasted SaveAS is trying to save as a file of same format as the target.
I am really dizzy now and tend to consider a MS Excel bug, how's that
sound?
Const xlExcel8 = 56
Const xlOpenXMLWorkbook = 51
Set wdo = CreateObject("Excel.Application")
Set wdoc = wdo.Workbooks.Open("c:\path\to\foo.xlsx")
' This works, but only to save as bar.xls, which "resolved" my original problem
wdoc.SaveAs "c:\path\to\bar.xlsx", xlOpenXMLWorkbook 'Sacrificed line to *activate* the following line of saving ...
wdoc.SaveAs "c:\path\to\bar.xls", xlExcel8
' This works, but only to save as bar.xlsx,
' wdoc.SaveAs "c:\path\to\bar.xls", xlExcel8 'Sacrificed line to *activate* the following line of saving ...
' wdoc.SaveAs "c:\path\to\bar.xlsx", xlOpenXMLWorkbook
' While this doesn't work at all
' wdoc.SaveAs "c:\path\to\bar.xls", xlExcel8
' wdoc.SaveAs "c:\path\to\bar.xls", xlExcel8
wdoc.Close
wdo.Quit