Avatar of Sigh_Man
Sigh_Man

asked on 

how to perform a Word mailmerge to a particular record in SQL database using Find Recipient

I have a VB.Net application which performs a Word document mail merge without input from the user.  An excerpt of the code is pasted below.  In my code, the merge is carried out using the desired record  by passing the relevant record number to the mail merge process using:
.FirstRecord = [RecordNumber]
.LastRecord = [RecordNumber]
...as shown in the code excerpt attached.
This method however assumes the order of the datasource (and hence the record number of the desired record) is known at the time the merge is executed.  This is the issue; I do not always know the order, and therefore I want to do the mailmerge using:
WordBasic.MailMergeFindEntry
...to find the record by harnessing Word's "Find Recipient" feature in the mailmerge toolbar, which finds a specific record in the list by searching for text.  I therefore need to know...
***How can I pass a value to the Find Recipient feature of Word?***
Please note this solution needs to work for all versions of Word from 2002 onwards, and must be fully automated - ie not require any user input during the mail merge process.
...
With oWord
     With .ActiveDocument.MailMerge
          .Destination = wdSendToNewDocument
          .SuppressBlankLines = True
          With .DataSource
               .FirstRecord = RecordNumberInMerge
               .LastRecord = RecordNumberInMerge
          End With
          .Execute(Pause:=False)
     End With
...

Open in new window

.NET ProgrammingMicrosoft Word

Avatar of undefined
Last Comment
Sigh_Man
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Sigh_Man
Sigh_Man

ASKER

Thank you.
And sorry for the delayed response.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo