Setting a Mail Merge Data source in Word Automation

Discussions specific to Team Developer 5.1.

Setting a Mail Merge Data source in Word Automation

Postby andy.anderson » Tue Jul 13, 2010 11:10 am

Hello,

I am trying to open a Word document as a Mail Merge doc, then dynamically update it's data source. I am getting an error '80020005' with the data source call. ANy suggestion?

Code: Select all
Function: OpenNamedTemplate
   Description:
   Returns
      Boolean:
   Parameters
      String: templateFileName
   Static Variables
   Local variables
      FunctionalVar: vTemplateName
         Class: Variant
      FunctionalVar: vOptional
         Class: Variant
      FunctionalVar: vNew
         Class: Variant
      FunctionalVar: vFormat
         Class: Variant
      FunctionalVar: vVisible
         Class: Variant
   Actions
      If iWord__Application.PropGetDocuments(oWord_Documents)
         Call vTemplateName.SetString( templateFileName )
         Call vNew.SetBoolean( FALSE )
         Call vVisible.SetBoolean( TRUE )
         Call vFormat.SetNumber( 0, 0 )
         Call vOptional.MakeOptional()
         ! We open our word template
         If oWord_Documents.Add( vTemplateName, vNew, vOptional, vOptional, iWord__Document )
            Call iWord__Document.Activate(  )
            Call iWord__Document.PropGetMailMerge( oMail_Merge )
            Call oMail_Merge.OpenDataSource( 'c:\\merge.txt', vFormat, vFalse, vFalse, vFalse, vFalse, vFalse, vFalse, vFalse, vFalse, vFalse, vFalse, vFalse, vFalse, vFalse, vFalse )
            Return TRUE
      Return FALSE


Thanks,
Andy Anderson
HAB, Inc.
andy.anderson
 
Posts: 7
Joined: Tue May 04, 2010 12:27 pm

Return to Team Developer 5.1

Who is online

Users browsing this forum: No registered users and 1 guest