Click here to Skip to main content
15,123,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been supplied an excel XLSM file that has been built by someone else and has vba macro's.

I am wanting to populate data into the fields of the xlsm using python.
There are a set of field names such as CustomerName, Address etc.

What I want to do is create a new xlsm from the original sheet, then set values such as CustomerName and save to another xlsm file.

I have made an attempt using openpyxl below. I am wanting to know if this looks like a good approach and also wanting to know how I update the field CustomerName

What I have tried:

I have tried using openpyl as follows
from openpyxl import Workbook
from openpyxl import load_workbook
wb = Workbook()

customer_name = "dave"

# and the workaround
wb = load_workbook('ANZ.xlsm', keep_vba=True)
sheet = wb.active
sheet["CustomerName"] = customer_name
wb.save('ANZ2.xlsm')
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900