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
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