Run Macro from Python

You can use xlwings package to perform different actions in Excel from Python.

Filepath of the macro:   wb = Workbook(‘Z:\\MacroVar.xlsm‘)

Name of the Macro to run:  Application(wb).xl_app.Run(‘MacroVar‘)

#PYTHON 2.7 
from xlwings import Workbook, Application
wb = Workbook('Z:\\MacroVar.xlsm')
Application(wb).xl_app.Run('MacroVar')

Interested in learning new skills?