title: Handle Excel Message Box from Within Python using Win32com
body: <p>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?</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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. </p>
  
  <p>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?</p>
  
  <p>Here is the patched together pieces that seem to work</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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</p>
  
  <pre><code>srce.CheckCompatibility='False' 
  </code></pre>
  
  <p>is because I am not saving the srce object I am saving some type of copy of it??</p>
  
  <p>Back to the mines.  </p>
  
  <p>False Hope I was not successful when I tried srce.CheckCompatibility='False'</p>
  
  <p>Sorry for any confusion</p>
  
  <p>Well now I am confused even more than usual this behavior is odd</p>
  
  <pre><code>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
  &gt;&gt;&gt; 'asked'  # I put this here to reinforce the fact that  I was asked
  'asked'
  &gt;&gt;&gt; srce.CheckCompatibility='False'    # again I try to assign the attribute 
  &gt;&gt;&gt; srce.SaveAs(r'c:\newtttxt78653.xls',FileFormat=1)   # I try to save it again
  &gt;&gt;&gt; 'did not ask'                                       #it saves this time w/o asking
  'did not ask'
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>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.</p>