HELP!! -- Word formatting on the fly in a mail merge

N

Nick

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
 
W

Word Heretic

G'day Nick <[email protected]>,

As you insert, the insert returns a range that represents the insert.
This range can then be formatted using Range.Font or whatever.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Nick reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top