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?
Asked
Active
Viewed 2.8k times
1 Answers
2
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()

Tomerikoo
- 18,379
- 16
- 47
- 61

EkaterinaSS
- 21
- 2
-
Note that `office.Quit()` will close all excel instances you have open. – Raf Feb 11 '21 at 10:10