Link to home
Start Free TrialLog in
Avatar of scott769
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_PARAMNOTFOUND, VT_ERROR);


    _Application app;  // app is the Word _Application object

    // Start Word and get Application object...
    if(!app.CreateDispatch("Word.Application"))
    {
       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\\Desktop\\parsing.doc";
       
      testDoc.AttachDispatch(docs.Open(     COleVariant(fileName,VT_BSTR),                                             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.
                  );
       }
ASKER CERTIFIED SOLUTION
Avatar of corduroy9
corduroy9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CleanupPing
CleanupPing

scott769:
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.