5

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?

1 Answer 1

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()
Sign up to request clarification or add additional context in comments.

1 Comment

Note that office.Quit() will close all excel instances you have open.

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.