Silent SaveAs when using the Excel win32com module

Discussion in 'Python' started by Chris, Sep 10, 2007.

  1. Chris

    Chris Guest

    I'm trying to create an excel file which will act as a log, however I
    want to overwrite the file if it exists.

    Looking at the SaveAs method I can't find anything that would allow
    it. I don't want the prompt to appear to ask whether to replace the
    file or not. I just want to replace it without thinking.

    Thanks in advance.
     
    Chris, Sep 10, 2007
    #1
    1. Advertisements

  2. Chris

    Chris Guest

    Googling around I found that a way around this is to just delete the
    file before you save (if it exists)... any other solutions?
     
    Chris, Sep 10, 2007
    #2
    1. Advertisements

  3. Chris

    Tim Golden Guest

    xl.DisplayAlerts = 0

    where xl is the Application object.

    TJG
     
    Tim Golden, Sep 10, 2007
    #3
  4. Chris

    MRAB Guest

    It's more Pythonic to delete the file and catch the exception if it
    doesn't actually exist.
     
    MRAB, Sep 10, 2007
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.