From: mjlaali on
The code is bigger than what could be included here. It is developed in
multiple classes using MFC. But I summarized it below:

Documents docs = m_wordApplication.GetDocuments();

m_document = docs.Open(COleVariant(filePathCStr), COleVariant((short)FALSE),
COleVariant((short) FALSE), COleVariant((short)FALSE), optionalArgument,
optionalArgument, COleVariant((short) FALSE),optionalArgument,
optionalArgument,
optionalArgument, optionalArgument, COleVariant((short) FALSE),
optionalArgument,
optionalArgument, COleVariant((short) TRUE), optionalArgument);


m_listOfParagraphs = m_document.GetParagraphs();
m_listOfSentences = m_document.GetSentences();

/////////////open output doc
CString toBeOpenedFilePath(m_filePath.c_str());

m_outDocument = docs.Open(COleVariant(toBeOpenedFilePath),
COleVariant((short)FALSE),
COleVariant((short) FALSE), COleVariant((short)FALSE), optionalParam,
optionalParam, COleVariant((short) FALSE),optionalParam, optionalParam,
optionalParam, optionalParam, COleVariant((short) FALSE), optionalParam,
optionalParam, COleVariant((short) TRUE), optionalParam);
Range docRange = m_outDocument.Range(optionalParam, optionalParam);

docRange.SetNoProofing(TRUE);
///////////////////////////////
.
.//some code
.
//loop on all sentences of the file
sentenceRange = m_listOfSentences.Item(m_indexOfNextSentenceToBeRead);

CString resultCStr = sentenceRange.GetText();
.
.//some code
.
string translation = aTranslatorEngine(resultCStr);

//find the original sentence in the output file and replace it with
translation
//end loop

Thanks,