Reading and writing an xlsm file results in corrupted file
Created originally on Bitbucket by bartev (Bartev Vartanian)
I'm trying to read an existing xlsm file and write it out. I've tried writing to the same file, and also to a new filename, but after saving, the new file cannot be opened by excel
I'm running
Excel Mac 2011
Python 2.7.6 :: Anaconda 1.9.1 (x86_64)
MacBook Pro 2.3GHz, Intel Core i7
OS X 10.9.2
openpyxl 1.8.5 installed via pip
#!python
#!/usr/bin/env python
import openpyxl as px
from openpyxl import Workbook
from openpyxl import load_workbook
# Open excel file
macrofname='test_macro.xlsm'
wb = load_workbook(macrofname)
# wb.save('newfile.xlsm')
wb.save(macrofname)
Before running the script,
#!python
32407 Mar 25 13:30 test_macro.xlsm
After running the script,
#!python
5977 Mar 25 15:17 test_macro.xlsm
Attachments: test_macro.xlsm