Ruby saveas .XLSM, format code
-
I thought 52 was the code to save as an .xlsm file, but I get an UndefinedConversionError.
workbook.SaveAs("C;\TestFolder\TestAddImage.xlsm",52)
-
Did you accidentally post in the wrong forum? There is no workbook object and no SaveAs method in SketchUp or in native Ruby...
-
No Steve, he's fine. He uses the Ruby standard
WIN32OLE
library to connect SketchUp with Excel workbooks.This library basically exposes the VBA object model of Excel to Ruby. SO he's attempting to make a OLE call to Excel's VBA "SaveAs" method.
This is the entry page for the Excel VBA object model:
https://msdn.microsoft.com/en-us/library/ff194068.aspxThis page coves the
Workbook
object:
https://msdn.microsoft.com/en-us/library/ff835568.aspxThis page is for the
Workbook.SaveAs
method:
https://msdn.microsoft.com/en-us/library/ff841185.aspxThis page is for the
XlFileFormat
Enumeration, whose members are to be used in the 2nd argument toWorkbook.SaveAs
:
https://msdn.microsoft.com/en-us/library/ff198017.aspxThe XLSM format came out in 2007.
But has it been superseded in newer Office versions ?List of Microsoft Office filename extensions:
https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensionsOffice Open XML (Microsoft invented standard, and copyright holder.)
https://en.wikipedia.org/wiki/Office_Open_XML
Not to be confused with:
OpenOffice.org XML (obsolete, superseded by OpenDocument):
https://en.wikipedia.org/wiki/OpenOffice.org_XMLOpenDocument (The FREE international standard):
https://en.wikipedia.org/wiki/OpenDocument -
@davesexcel said:
I thought 52 was the code to save as an .xlsm file, but I get an UndefinedConversionError.
> workbook.SaveAs("C;\TestFolder\TestAddImage.xlsm",52) >
As a general rule, try to use the interface's constants rather than direct use of integers. (The integers could change in the future and break your code.)
Microsoft forums:
Excel for Developers:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=exceldev%26amp;filter=alltypes%26amp;sort=lastpostdescOpen XML Format SDK
https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=oxmlsdk%26amp;filter=alltypes%26amp;sort=lastpostdesc -
I did a search in the MS Excel Dev forum on "+SaveAs +xlsm +UndefinedConversionError", and got 947 hits. (You can browse those yourself.)
At this point I would double-check that any macros in the Workbook do not have errors, that could give the file export routine issues.
Advertisement