I am inserting text into my document via a vb6 program - it does this just fine (when I press the button, it inserts the text as required).
However, I'd like it to insert a mergefield (its a letter customisation program) - but I cant seem to do it.
Below is the slice of code that does it (label2's caption contains the code which relates to the mergecode)
Is there anyway that I can automatically tell word that this is a mergefield coming in, not normal text?
Thanks,
However, I'd like it to insert a mergefield (its a letter customisation program) - but I cant seem to do it.
Below is the slice of code that does it (label2's caption contains the code which relates to the mergecode)
Code:
Clipboard.Clear
Clipboard.SetText frmDocTailAssistant.Label2.Caption, vbCFText 'Put text on Clipboard
On Error Resume Next
Set wordobj = GetObject(, "Word.Application") 'get existing instance of Word if there is one
If Err Then Set wordobj = CreateObject("Word.Application") ' otherwise create a new one
On Error GoTo 0
With wordobj
.Visible = True
If .Documents.Count = 0 Then 'no docs
.Documents.Add 'so create one
Else
On Error Resume Next
.Documents("Document1").Activate 'activate the special doc if loaded
If Err Then
.Documents.Add 'not loaded so create a new one
End If
On Error GoTo 0
End If
.Selection.Paste 'paste clipboard to word doc
End With
Is there anyway that I can automatically tell word that this is a mergefield coming in, not normal text?
Thanks,