scott769
asked on
Automation of MS Word 2000
I need to automate MS Word 2000 so that I can take a list of files, open them, read an email address contained in the first line of the document, and then send that document to the specified email address. This is what I have so far, which isn't very much at all...and I got this from MSDN. Thank you for any help. - Scott
// Convenient values declared as ColeVariants.
COleVariant covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_P ARAMNOTFOU ND, VT_ERROR);
_Application app; // app is the Word _Application object
// Start Word and get Application object...
if(!app.CreateDispatch("Wo rd.Applica tion"))
{
AfxMessageBox("Couldn't start Word.");
}
else
{
//Make Word Visible and display a message
app.SetVisible(true);
Documents docs(app.GetDocuments());
_Document testDoc;
CString fileName = "C:\\Documents and Settings\\Administrator\\D esktop\\pa rsing.doc" ;
testDoc.AttachDispatch(doc s.Open( COleVariant(fileName,VT_BS TR), covFalse, // Confirm Conversion.
covFalse, // ReadOnly.
covFalse, // AddToRecentFiles.
covOptional, // PasswordDocument.
covOptional, // PasswordTemplate.
covFalse, // Revert.
covOptional, // WritePasswordDocument.
covOptional, // WritePasswordTemplate.
covOptional, // Format. // Last argument for Word 97
covOptional, // Encoding // New for Word 2000/2002
covTrue) // Visible
);
/* What Goes Here?? */
app.Quit(covFalse, // SaveChanges.
covTrue, // OriginalFormat.
covFalse // RouteDocument.
);
}
// Convenient values declared as ColeVariants.
COleVariant covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_P
_Application app; // app is the Word _Application object
// Start Word and get Application object...
if(!app.CreateDispatch("Wo
{
AfxMessageBox("Couldn't start Word.");
}
else
{
//Make Word Visible and display a message
app.SetVisible(true);
Documents docs(app.GetDocuments());
_Document testDoc;
CString fileName = "C:\\Documents and Settings\\Administrator\\D
testDoc.AttachDispatch(doc
covFalse, // ReadOnly.
covFalse, // AddToRecentFiles.
covOptional, // PasswordDocument.
covOptional, // PasswordTemplate.
covFalse, // Revert.
covOptional, // WritePasswordDocument.
covOptional, // WritePasswordTemplate.
covOptional, // Format. // Last argument for Word 97
covOptional, // Encoding // New for Word 2000/2002
covTrue) // Visible
);
/* What Goes Here?? */
app.Quit(covFalse, // SaveChanges.
covTrue, // OriginalFormat.
covFalse // RouteDocument.
);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.