Skip to content Skip to sidebar Skip to footer

Possible Bug? Xlwings Cannot Run An Excel Macro?

I am having a problem getting xlwings to run a macro from Python. Despite following the code from xlwings documentation, I cannot get xlwings to execute an Excel macro. For instanc

Solution 1:

Try the following:

In VBA:

Sub Test(number)
   Set ws = Worksheets("Hoja1")
   ws.Range("A1").Value = number
EndSub

In python:

import xlwings as xw
wb1 = xw.Book('Libro1.xlsm')    
macro=wb1.macro('Test')
macro(10)
print('done.')

Post a Comment for "Possible Bug? Xlwings Cannot Run An Excel Macro?"