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

  • SEARCH
  • Home
  • 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 4048970
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:53:07+00:00 2026-05-20T13:53:07+00:00

I am trying to process some files that were supposed to be xls files

  • 0

I am trying to process some files that were supposed to be xls files but it turns out they are something else (according to some help I received on the python-excel board these are Web Archive files or (Single File Web Page (*.mht, *.mhtml) ). I can open the files with Excel but I get a message that has to be dismissed before I can move forward. The message is – The file you are trying to open filename.xls is in a different format than specified by the file extension. Verify that the file is not corrputed and isfrom a trusted source before opening the file. Do you want to open the file?

If I hit yes, the file opens and it looks like an excel workbook. Some sheet names are truncated. Sure enough, when I hit Save as the default format that shows up is the single file web page.

Now, if I SaveAs and select excel 97-2003 format, rename to my new name and hit the save button the file then opens with Excel with no future questions.

I have been scratching around trying to figure out how to write some code to open and save these as true xls files so I don’t have to have someone offshore open and save them.

I have gotten really close but am stuck on one last issue, when I save it with a new fileformat I get a warning box warning me that there will be some minor lost of fidelity. I can’t figure out how to supress it and accept that loss of fidelity?

Here is the patched together pieces that seem to work

import win32com.client
xl=win32com.client.Dispatch('Excel.Application')
xl.visible=0  # I have noticed that if I don't set visible to 0 I can't get any response
srce=xl.Workbooks.Open(r'c:\testdd.xls') # testdd is my file that is evidently really not an excel file
srce.SaveAs(r'c:\newtttxt2.xls',FileFormat=1)  # this is when the message box pops up

I found reference to anattribute called CheckCompatibility. It seems to be an attribute of a workbook object. And I guess I cannot use it in the form

srce.CheckCompatibility='False' 

is because I am not saving the srce object I am saving some type of copy of it??

Back to the mines.

False Hope I was not successful when I tried srce.CheckCompatibility=’False’

Sorry for any confusion

Well now I am confused even more than usual this behavior is odd

srce=xl.Workbooks.Open(r'c:\testdd.xls') # I open the file
srce.CheckCompatibility='False' # I try to assign the attribute to srce

srce.SaveAs(r'c:\newtttxt7865.xls',FileFormat=1)  #when I SaveAs the compatibility dialog asks if I want to continue
>>> 'asked'  # I put this here to reinforce the fact that  I was asked
'asked'
>>> srce.CheckCompatibility='False'    # again I try to assign the attribute 
>>> srce.SaveAs(r'c:\newtttxt78653.xls',FileFormat=1)   # I try to save it again
>>> 'did not ask'                                       #it saves this time w/o asking
'did not ask'
>>> 

I wonder if I add a make.py file as described in the com help if this would be addressed? I am starting to wonder if the issue is that srce does not know what attributes it has yet, it accepts the assignment but it is not put into play until some even happens? If I sound stupid that is okay.

  • 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-05-20T13:53:07+00:00Added an answer on May 20, 2026 at 1:53 pm

    Please see my answer to your other question on this issue.

    The reason it doesn’t display a dialog box for the second call to SaveAs(...) is that the file format is not changing on the second call, the file format only changes on the first call.

    What you want is to add

    >>> xl.DisplayAlerts = False
    

    before calling SaveAs().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to process some files that are named xls and can be
I am trying to process some XML to reform it so that this input,
I'm trying to make a console app that would monitor some process and restart
I am trying to process files one at a time that are stored over
I've been trying to parse some huge XML files that LXML won't grok, so
So, I've got a Linux process where I'm trying to manage some files on
I have some corrupted Gzip log files that I'm trying to restore. The files
I have an admin process that scans some directories and files to see if
I am trying to create a process that manage some other process in the
I need some help. I'm trying to upload files using <input type=file> . Here

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.