Word 2007 saves a Docx as a 97-2007 doc

Add-in Express™ Support Service
That's what is more important than anything else

Word 2007 saves a Docx as a 97-2007 doc
 
Michael Bendtsen




Posts: 58
Joined: 2007-06-27
I have an add-in that saves the current document to a web site. In Word 2007 the user can set the default format for save to 97-2003 document (.doc).

The problem is that I only know that the program is Word 2007 so I save the document as test.docx, but the file is of type doc. This means that when I tries to open the document the document is opened in Word 2007 but fails because it is not of type docx.

Is there any way for me to know which type Word is saving as?
Posted 08 Oct, 2008 10:45:10 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hello Michael,

What code do you use to save a file?
.NET, Extended MAPI, Windows Phone & RT
Posted 08 Oct, 2008 11:02:26 Top
Michael Bendtsen




Posts: 58
Joined: 2007-06-27

        protected override void SaveAs(string filename)
        {
            object fileName = filename;
            object missing = System.Reflection.Missing.Value;
            object False = false;
            object True = true;

            Application.ActiveDocument.SaveAs(ref fileName, ref missing, ref missing, ref missing, ref False, ref missing, ref missing, ref missing, ref missing, ref  missing, ref missing);
        }


Application is of type Word._Application.
Posted 10 Oct, 2008 04:51:22 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hello Michael,

You didn't specify the format of the file. Please note that the second parameter in the SaveAs method indicates the file format.

To get assistance with host applications’ objects, their properties, and methods as well as help info, use the Object Browser. Go to the VBA environment (in the host application, choose menu Tools / Macro / Visual Basic Editor or just press Alt+F11), press F2, select the host application (also Office and MSForms) in the topmost combo and/or specify a search string in the search combo. Select a class/property/method and press F1 to get the help topic that relates to the object.
.NET, Extended MAPI, Windows Phone & RT
Posted 10 Oct, 2008 05:49:17 Top
Michael Bendtsen




Posts: 58
Joined: 2007-06-27
I can see that my referenced interop is version 8.1 which contains these formats:
        
        wdFormatDocument = 0,
        wdFormatTemplate = 1,
        wdFormatText = 2,
        wdFormatTextLineBreaks = 3,
        wdFormatDOSText = 4,
        wdFormatDOSTextLineBreaks = 5,
        wdFormatRTF = 6,
        wdFormatEncodedText = 7,
        wdFormatUnicodeText = 7,
        wdFormatHTML = 8,


I'm missing the XML format (2007).

What do I do if I want to support both Office 2003 and Office 2007? Which interop's do I need a reference to?
Posted 13 Oct, 2008 06:18:46 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Michael,

Please read the "Add-in Express Tips and Notes" section in the documentation (see the adxnet.pdf file).
.NET, Extended MAPI, Windows Phone & RT
Posted 13 Oct, 2008 06:25:53 Top