Any debugger help?

M

Matthew Chan

I have find the following code to overwrite the mailmerge field with the
recordset value. but find error occur while there is null field of recordset
value.

loWordApp.Documents.Add (asMergeDoc) 'Add an instance For Each record
Set loDoc = loWordApp.ActiveDocument 'Utilize newest instance
loDoc.Activate
Do Until aors.EOF

ReDim lsaFldNames(loDoc.MailMerge.Fields.Count)

Debug.Print loDoc.Fields.Item(1).Code

For Nc = 1 To loDoc.MailMerge.Fields.Count
lsFieldName =
Trim(Right(loDoc.MailMerge.Fields(Nc).Code,
Len(loDoc.MailMerge.Fields(Nc).Code) - 11))
lsaFldNames(Nc) = lsFieldName
Next Nc

For Nc = 1 To loDoc.MailMerge.Fields.Count
loDoc.MailMerge.Fields(1).Select

lbmatched = False

For llmatch = 0 To UBound(larrTTXField)
If larrTTXField(llmatch) = lsaFldNames(Nc) Then
lbmatched = True
Exit For
End If
Next


If lbmatched = True Then
If Trim(aors(lsaFldNames(Nc))) = "" Then
Else
loGlobVar.Selection.TypeText
Trim(aors(lsaFldNames(Nc)))
End If

End If
Next Nc

loDoc.MailMerge.Destination = wdSendToNewDocument
loDoc.SaveAs asOutputFullPathFilename

aors.MoveNext
Loop
aors.Close
loWordApp.Quit
 
C

Cindy M -WordMVP-

Hi Matthew,
I have find the following code to overwrite the mailmerge field with the
recordset value. but find error occur while there is null field of recordset
value.
Well, leaving aside the question whether merge fields are really meant for
this sort of thing (they're NOT!), which line of the code you posted is
causing the error?

Generally, since Word works entirely with strings, for an null string value
you can append and empty string: & ""

Not sure if this is the answer you're looking for, but perhaps it is :)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
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 :)
 

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