0

Morning,

I have a very simple VBA code which refreshers the addin i have in excel. This is below

Sub Refresh()
    ExecuteExcel4Macro "FDSFORCERECALC(False)"

    ActiveWorkbook.Save

    ActiveWorkbook.Close

End Sub

I have tried using xlsxwriter but i am unable to write anything but a macro to press which still means manually opening each file. Is there a way to automate this code into Python, so i can just iterate through files and refresh as I go?

Thanks

1 Answer 1

2

You could use the pywin32 module's COM support to manipulate the files programmatically. It will look something like this:

import win32com.client

xlApp = win32com.client.Dispatch("Excel.Application")
workBook = xlApp.Workbooks.Open("spreadsheet.xls")
xlApp.ExecuteExcel4Macro("FDSFORCERECALC(False)")
workBook.Save()
workBook.Close()
xlApp.Quit()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.