VB macro is lost in openpyxl 2.4.0

Issue #705 resolved
Hugh Foster
created an issue

The following code fails to keep the VBA macro when opening and writing data to an excel 2010 xlsm file.

    w_book = load_workbook(
        filename=os.path.join(out_dir, file_dir_name + ".xlsm"),

    # Add data to worksheet here   

    w_book.save(os.path.join(out_dir, file_name + ".xlsm"))

This works fine however in 2.3.5.

I've attached a test script and macro file. Note that you will have to change 2 path variables at the top of the script.

Also I'm using Python 3.4.3.

Comments (16)

  1. Hugh Foster reporter

    Further to this, the VBA macro is now preserved but some of the formatting is lost. Specifically the currency format in the pivot table is lost.

    This works in openpyxl 2.2.1 but seems to be broken in 2.3.5 and isn't working with this change for 2.4.1. Should I open a new item?

  2. Log in to comment