0

I use the Microsoft.Office.Interop.Excel; I try to save a XLS with compatibilty 97-2003 using the following

    private void CreationFichier(_Worksheet template, int nom)
    {
        _Workbook fichierCree = _excel.Workbooks.Add();
        fichierCree.DoNotPromptForConvert = true;
        fichierCree.CheckCompatibility = false;

        var feuilleActiveClasseurCree = (_Worksheet)fichierCree.Sheets[1];
        string nomFichier = (nom - 4).ToString() + ".xls";
        label3.Text = "Creation du fichier "+nomFichier+" ...";
        progressBar1.Value++;
        template.Copy(feuilleActiveClasseurCree);

        fichierCree.SaveAs(_folderdestination.SelectedPath + "\\" + nomFichier, XlFileFormat.xlExcel8);
        fichierCree.Close();
    }

But this creates a popup for checking the compatibilty - I don't want this popup.

https://i.stack.imgur.com/8zop9.png

Kara
  • 6,115
  • 16
  • 50
  • 57
user1740962
  • 111
  • 2
  • 16

1 Answers1

0

I did not find a way to fix this issue from just code but I did find a solution that works for me. In my case I am opening the same file as a template each time and saving it out as a new file. With Office.Interop.Excel._Application.Visible = true I can see better what is happening. I simply took the master template from my desktop Excel and re-saved it after checking the the don't show this dialog for this box again. Now when I use the file as a template it no longer interrupts my program with the dialog asking about saving for compatibility.

Also, to prevent any file access issues I do a System.IO.File.Copy of the template and then open and save my new file.

This is a late answer and may not solve your specific issue. I hope it is a help to anyone searching for a solution now.

Mike Grimm
  • 1,196
  • 7
  • 10