We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ArgumentException when setting SaveFormat

I feel certain this is a case of pilot error, but I've been unable to find the solution in either the documentation or the forum.

I am using Aspose.Words v 13.1.0.

I need to save an RTF file as a .DOC or .DOCX file (sometimes one, sometimes the other).

I sometimes need to password-protect the output.

If I assign a DocSaveOptions object to the document.Save method when saving as a DOC file, everything works properly.

If I assign a DocSaveOptions object when saving as a DOCX file, I get an ArgumentException with a message of "An invalid SaveFormat for this options type was chosen.".

The DocSaveOptions object is the only way I know of to assign a password. What's the proper way to address this issue with the DOCX format?

An example program is attached.


Jim McFadden/Unum, Chattanooga, TN

Hi Jim,

Thanks for your inquiry. OoxmlSaveOptions can be used to specify additional options when saving a document into the Docx, Docm, Dotx, Dotm or FlatOpc format. Please use the following code snippet for your requirement and read following documentation links for your kind reference.


<span style=“font-size:10.0pt;
font-family:“Courier New”;color:#2B91AF;mso-font-kerning:0pt;mso-ansi-language:
PL;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:
“Courier New”;mso-font-kerning:0pt;mso-ansi-language:PL;mso-no-proof:yes”> doc
= new Document(MyDir

  • “Source.rtf”);<o:p></o:p>

OoxmlSaveOptions opt = new OoxmlSaveOptions(SaveFormat.Docx);

opt.Compliance = OoxmlCompliance.Iso29500_2008_Transitional;

opt.Password = "password";

doc.Save(MyDir + "AsposeOut.docx", opt);

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.