I would like to write a VBA diff program in (preferably) Python. Is there a Python library that will allow me to read the VBA contained in an Excel spreadsheet?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s some quick and dirty boilerplate to get you started. It uses the Excel COM object (a Windows only solution):
This prints the silly macro I recorded for this example:
Note that
LinesandVBComponentsuse 1-based indexing.VBComponentsalso supports indexing by module name. Also note that Excel requires backslashes in paths.To dive deeper see Pearson’s Programming The VBA Editor. (The above example was cobbled together from what I skimmed from there.)