1 year ago

#354908

test-img

Susaj S N

How to run Macro by selecting column A till the data exists

I am trying to run a macro from python and win32com.client. My macro is working fine when i am trying manually, Because it has to run by selecting column A and rows till data exists. Macro has Text column functionality and creating headings as well.

enter image description here

results enter image description here

But when i try from code it is not working as expected.

import win32com.client as wincl

excel_app = wincl.DispatchEx("Excel.application")
excel_workbook = excel_app.Workbooks.Open(Filename=temp_macro_template_file_path, ReadOnly=1)
excel_app.Visible = True
excel_app.Columns('A')
excel_app.Application.Run("Macroname")
excel_workbook.Save()
excel_app.Application.Quit()

This is what i am getting after this.

enter image description here

python-3.x

excel

vba

win32com

0 Answers

Your Answer

Accepted video resources