Last active
July 27, 2021 16:25
Convert DOCX to DOC | DOC to DOCX Programmatically using C++ | https://blog.aspose.com/2021/06/28/convert-docx-to-doc-or-doc-to-docx-using-cpp/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Read the complete article about converting DOCX to DOC or DOC to DOCX programmatically using C++ by visiting the following link. | |
https://blog.aspose.com/2021/06/28/convert-docx-to-doc-or-doc-to-docx-using-cpp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Iterate through the files in the directory | |
for (directory_entry& file : directory_iterator("SourceDirectory\\Word")) | |
{ | |
// Check file extension | |
if (file.path().extension().string() == ".doc") | |
{ | |
// Create an instance of the LoadOptions class | |
auto loadOptions = System::MakeObject<LoadOptions>(); | |
// Specify LoadFormat of input word document | |
loadOptions->set_LoadFormat(LoadFormat::Doc); | |
// Load the DOC file | |
System::SharedPtr<Document> doc = System::MakeObject<Document>((System::String)file.path().string(), loadOptions); | |
// Change the file extension | |
System::String fileName = (System::String)file.path().filename().string(); | |
fileName = fileName.Replace(u".doc", u".docx"); | |
// Save the DOCX file | |
doc->Save(System::String::Concat(u"OutputDirectory\\", fileName), SaveFormat::Docx); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an instance of the LoadOptions class | |
auto loadOptions = System::MakeObject<LoadOptions>(); | |
// Specify LoadFormat of input word document | |
loadOptions->set_LoadFormat(LoadFormat::Doc); | |
// Load source DOC file | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"SourceDirectory\\Word\\Sample 1.doc", loadOptions); | |
// Save the DOCX file | |
doc->Save(u"OutputDirectory\\output.docx", SaveFormat::Docx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Iterate through the files in the directory | |
for (directory_entry& file : directory_iterator("SourceDirectory\\Word")) | |
{ | |
// Check file extension | |
if (file.path().extension().string() == ".docx") | |
{ | |
// Create an instance of the LoadOptions class | |
auto loadOptions = System::MakeObject<LoadOptions>(); | |
// Specify LoadFormat of input word document | |
loadOptions->set_LoadFormat(LoadFormat::Docx); | |
// Load the DOCX file | |
System::SharedPtr<Document> doc = System::MakeObject<Document>((System::String)file.path().string(), loadOptions); | |
// Change the file extension | |
System::String fileName = (System::String)file.path().filename().string(); | |
fileName = fileName.Replace(u".docx", u".doc"); | |
// Save the DOC file | |
doc->Save(System::String::Concat(u"OutputDirectory\\", fileName), SaveFormat::Doc); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an instance of the LoadOptions class | |
auto loadOptions = System::MakeObject<LoadOptions>(); | |
// Specify LoadFormat of input word document | |
loadOptions->set_LoadFormat(LoadFormat::Docx); | |
// Load source DOCX file | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"SourceDirectory\\Word\\Sample 4.docx", loadOptions); | |
// Save the DOC file | |
doc->Save(u"OutputDirectory\\output.doc", SaveFormat::Doc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment