Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python to run excel macro

from win32com.client import Dispatch


def run_excel_macro():
    try:
        excel = Dispatch("Excel.Application")
        excel.Visible = True
        workbook = excel.Workbooks.Open(
            r"D:DocumentsBook1.xlsm")

        workbook.Application.Run("Module1.Example")
        workbook.SaveAs(r"D:DocumentsBook5.xlsm")
        excel.Quit()
    except IOError:
        print("Error")


if __name__ == "__main__":
    run_excel_macro()
Comment

PREVIOUS NEXT
Code Example
Python :: create a empty dataframe 
Python :: how to insert item at specifc index python 
Python :: spark df to pandas df 
Python :: numpy diff 
Python :: save model python 
Python :: print whole list python 
Python :: load image metadata with pil 
Python :: python 3.7.9 download 
Python :: go to line in python 
Python :: check if list elememnt in dataframe column 
Python :: Program to Compute LCM 
Python :: python finally keyword 
Python :: code to printing a binary search tree in python 
Python :: django get latest object 
Python :: python try except finally 
Python :: Python Selenium import WebElement 
Python :: python cut string to length 
Python :: python reading and writing files 
Python :: get file size python 
Python :: how to have player input in python 
Python :: conda create environment python 3 
Python :: remove na python 
Python :: pandas insert row 
Python :: set and tuple in python 
Python :: find number of unique keys in the dictionary 
Python :: Python numpy.flatiter function Example 
Python :: set points size in geopandas plot 
Python :: while loop odd numbers python 
Python :: pandas filter rows by value 
Python :: python dataframe replace in all dataframe 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =