Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2005

Tip: Looking for answers? Try searching our database.

HELP - Formating text on the fly during a mail merge via a DB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nick - 13 Jun 2005 18:13 GMT
Hello,

I am using a Microsoft Access 2003 DB and built a VB6 application on top
of it.  I need to creat a mail merged word document based on the results
of a search query issued by the user.  The contents of the letter to be
mail merged resides on a db table.  What I need to do is format the text
seperately for each paragraph (bold 1, underline another, etc.) as I
insert it into the document.

I have read about formatting test once its in the document, but what I
am looking for is to format it as it gets inserted.  Is there a way how
to do this?

Below is a procedure I have created that does a mail merge with the
document but there is no text formatting.  DocRs is the recordset which
contains the different paragraphs of the letter that must be formatted.

While Not searchrs.EOF   ' recordset that contains list of clients
     stemp = "Dear " & searchrs.Fields(3).Value & "," & vbCrLf & vbCrLf
& vbCrLf
    stemp = stemp & DocRs.Fields(3).Value & vbCrLf & vbCrLf
    stemp = stemp & DocRs.Fields(4).Value & vbCrLf & vbCrLf
    stemp = stemp & DocRs.Fields(5).Value & vbCrLf & vbCrLf & vbCrLf
    stemp = stemp & "Sincerely," & vbCrLf & vbCrLf & vbCrLf & vbCrLf
vbFormFeed
    searchrs.MoveNext
Wend

wordApp.Selection.Text = stemp

j = InStr(1, txtLocation.Text, ".doc", vbTextCompare)
If j = 0 Then
   txtLocation.Text = txtLocation.Text & ".doc"
End If
wordDoc.SaveAs txtLocation.Text

Is there someone that could lead me to the right direction in how to do
this.  Your help is much appreciated.

Thanks,

Nick
Cindy M  -WordMVP- - 03 Jul 2005 09:52 GMT
Hi Nick,

> I am using a Microsoft Access 2003 DB and built a VB6 application on top
> of it.  I need to creat a mail merged word document based on the results
> of a search query issued by the user.  The contents of the letter to be
> mail merged resides on a db table.  What I need to do is format the text
> seperately for each paragraph (bold 1, underline another, etc.) as I
> insert it into the document.

Look at the mail merge events.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.