WordApp.ActiveDocument.SaveAs does not save .docx files

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

WordApp.ActiveDocument.SaveAs does not save .docx files
SaveAs only saves docx files as original .doc files 
Andrei B




Posts: 89
Joined: 2009-09-30
If I open a .docx file in word, and I use WordApp.ActiveDocument.SaveAs with the "FileFormat" parameter set to wdOriginalDocumentFormat and set the "FileName" to something like "c:\test.docx", then it will save the active document to c:\test.docx, but when I open it in Word I get an error saying that to document is corrupt and needs to be repaired. However, if I rename the file to test.doc then it opens file with the original content.

How do I get WordApp.ActiveDocument.SaveAs to save .docx files? Thanks

Here is my code:

tempname := 'c:	est.docx';
      frmorig := wdOriginalDocumentFormat;
      olefalse := False;
      oletrue := True;
      oleempty := EmptyParam;
      oleembed := WordApp.ActiveDocument.EmbedTrueTypeFonts;
      oleenc := msoEncodingAutoDetect;

      origdocpath := WordApp.ActiveDocument.FullName;

      WordApp.ActiveDocument.SaveAs(tempname, frmorig, olefalse, oleempty,
        olefalse, oleempty, olefalse, oleembed, oletrue, olefalse, oletrue);
Posted 02 Dec, 2009 15:14:22 Top
Andrei Smolin


Add-in Express team


Posts: 19138
Joined: 2006-05-11
Andresi,

You need to use wdFormatDocumentDefault to save in the DOCX format. In such situations I recommend checking the help reference for the object model.

Getting Help on COM Objects, Properties and Methods

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.


In the VBA Browser, that constant is defined as follows:
Const wdFormatDocumentDefault = 16 (&H10)


Andrei Smolin
Add-in Express Team Leader
Posted 03 Dec, 2009 07:25:20 Top
Andrei B




Posts: 89
Joined: 2009-09-30
it works thanks
Posted 03 Dec, 2009 10:46:19 Top
Andrei Smolin


Add-in Express team


Posts: 19138
Joined: 2006-05-11
Thank you very much for letting me know.


Andrei Smolin
Add-in Express Team Leader
Posted 03 Dec, 2009 13:23:55 Top