Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:13:21+00:00 2026-06-08T10:13:21+00:00

I am using python to open an excel file and make some changes and

  • 0

I am using python to open an excel file and make some changes and then I need to save it. I can get everything done except the save part. How do I get python to save the file. If I save it manual I get the pop up box and I can click save, but I don’t want to have to manually click save. I want python to just save it and close excel. I need help, this is what I have. but it won’t work. I can get it to save but not close????

 import win32com.client
 import os


 xl = win32com.client.DispatchEx("Excel.Application")
 xl.workbooks.open("C:\file.xlsm")
 xl.run("file.xlsm!macro")
 xl.Visible = True
 xl.save = true
 xl.close
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:13:24+00:00Added an answer on June 8, 2026 at 10:13 am

    You need to get a hook to the workbook object and apply the save as an argument to the close method:

    xl = win32com.client.DispatchEx("Excel.Application")
    wb = xl.workbooks.open("C:\file.xlsm")
    xl.run("file.xlsm!macro")
    xl.Visible = True
    wb.Close(SaveChanges=1)
    xl.Quit()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to open a write-protected ms excel 2007 file using win32com in python
I'm using the Excel.Application COM object from a Python program to open a CSV
I am trying to create a csv file using python that is truly Excel-compatible
Using Python I am trying to analyze a tab delimited file. I open the
I'm using python to read a text file with the segment below (can't post
Using Python to append CSV file, I get data every other row. How do
I open a file using python to find whether a predefined set of words
When using os.system to open a file, eg: os.system(r'C:/foo.txt') , the current Python process,
[Using Python 3.2] If I don't provide encoding argument to open , the file
I'm using python-mock to mock out a file open call. I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.