Skip to content

Mac: update wb reference when saving as #626

@ahmedelz

Description

@ahmedelz

Hi,

I'm trying to save the sheet as .xlsb on Mac OS X.. I have this piece of code:

wb = xw.Book(fullname=fname)
.....
# lots of code that increases the workbook file size significantly
....
if sys.platform.startswith('darwin'):
    wb.save()
    wb.api.save_workbook_as(filename=xw._xlmac.posix_to_hfs_path(fname[:-5] + '.xlsb'), file_format=xw.constants.FileFormat.xlExcel12, overwrite=True)
wb.close()

However, this seems to fail in appscript on the save_workbook_as line with the following piece of the traceback:

    wb.api.save_workbook_as(filename=xw._xlmac.posix_to_hfs_path(fname[:-5] + '.xlsb'), file_format=xw.constants.FileFormat.xlExcel12, overwrite=True)
  File "/Library/Python/2.7/site-packages/aeosa/appscript/reference.py", line 498, in __call__
    raise CommandError(self, (args, kargs), e, self.AS_appdata)
appscript.reference.CommandError: Command failed:
          OSERROR: -50
          MESSAGE: Parameter error.
          COMMAND: app(pid=29029).workbooks[....].save_workbook_as(file_format=50, overwrite=True, filename=u'.....xlsb')

The executed command seems to be what I was expecting but not sure why it is failing. Any suggestions or hints?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions