ArcGIS Pro (2.9.x) Notebook save .xlsm Macro to .xlsx

500
1
11-22-2022 02:33 PM
ElisseDeleissegues1
New Contributor III

https://stackoverflow.com/questions/39292179/how-to-convert-xlsm-macro-enabled-excel-file-to-xlsx-us...

I am attempting to use the code in the above Stack post to save a .xlsm to a .xlsx using win32com in Notebook and it is not working.

There are many other suggestions for converting a .xlsm to .xlsx and each one of them relies on using some version of "Save" (SaveCopy, SaveAs, etc.) and none of them are working for me.

The error I keep getting is: xlsxwriter object has no attribute 'fill in the blank'

Keep in mind that I am fairly new at this (thank you)

Please help!

#Export xlsm to xlsm)

import win32com.client

excel = win32.gencache.EnsureDispatch('Excel.Application')
excel.Application.Quit()

# Load the .XLSM file into Excel

wb = excel.Workbooks.Open(r'S:\ALL\GIS\Software\NIGHTLY_UPDATES\GIS_CAMA_RECONCILIATION\RECONCILIATION_STAGING\GIS_CAMA_Reconciliation1.xlsm')

# Save it in .XLSX format to a different filename

excel.DisplayAlerts = False
writer.DoNotPromptForConvert = True
writer.CheckCompatibility = False
writer.SaveAs(r'S:\ALL\GIS\Software\NIGHTLY_UPDATES\GIS_CAMA_RECONCILIATION\RECONCILIATION_STAGING\GIS_CAMA_Reconciliation1.xlsx', FileFormat=51, ConflictResolution=2)
excel.Application.Quit()
del excel
print(".XLSM Saved as .XLSX")

AttributeError: 'XlsxWriter' object has no attribute 'SaveAs'


   

 

0 Kudos
1 Reply
by Anonymous User
Not applicable

It would help if you formatted your code.  Click the ... then </> to paste and select the code flavor.

I don't see where writer is created.  XlsxWriter and win32com has some quirks.

Have you tried wb.saveAs(..)?

0 Kudos