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

Free Support Forum - aspose.com

Encrypt Word error

Hi,

I’m using Words for C++, and got System::ArgumentException: An invalid SaveFormat for this options type was chosen..
Any docx file with the following code will fail.

void WordEncrypt() {
    auto doc = System::MakeObject<Aspose::Words::Document>(u"Borders.docx");
    auto opt = System::MakeObject<Aspose::Words::Saving::DocSaveOptions>();// Aspose::Words::SaveFormat::Docx);
    opt->set_SaveFormat(Aspose::Words::SaveFormat::Docx); 
    opt->set_Password(u"111");
    doc->Save(u"tutorial-0.docx", opt);
}

@kngstr for DOCX document format you have to use OoxmlSaveOptions.
DocSaveOptions accepts only DOC and DOT SaveFormat.

@alexey.noskov

Thanks. It does work.