fk.
fk.

Reputation: 51

How to use Python's win32com to "save as" an Excel file?

I have a small Python code to open an Excel file. Now I want to "Save As" with a different name but same format. How do I do that?

Upvotes: 5

Views: 30399

Answers (1)

EkaterinaSS
EkaterinaSS

Reputation: 21

Just use the SaveAs method:

import win32com.client 

office = win32com.client.Dispatch("Excel.Application") 
wb = office.Workbooks.Open("C:/FileName.xlsx") 
wb.SaveAs(Filename="C:\\NewFileName.xlsx")
wb.Close()
office.Quit()

Upvotes: 2

Related Questions