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); |
|
Andrei Smolin
Add-in Express team
Posts: 18816
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 |
|
Andrei B
Posts: 89
Joined: 2009-09-30
|
|
Andrei Smolin
Add-in Express team
Posts: 18816
Joined: 2006-05-11
|
Thank you very much for letting me know.
Andrei Smolin
Add-in Express Team Leader |
|