Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA for [Shift][Ctrl][F9] when using mailmerge 1

Status
Not open for further replies.

weeze2

Technical User
Jun 18, 2002
129
DK
Hi!

VBA for [Shift][Ctrl][F9] when using mailmerge:

Can anyone help me? How can I get hold of the VBA code for removing mergefields from a document and replacing it with plain text - Like when you use [Shift][Ctrl][F9]?

And a second part to the question - can one restrict the effect of this, so that { FORMTEXT } fields are not removed?

Thanks! Have a nice day!
 
Hi weeze2,

The VBA is ..

[blue][tt]Field(s)[/tt][tt].Unlink[/tt][/blue]

where [tt]Field(s)[/tt] is a reference to the Field or Fields you want to change.

There is no special way to restrict the operation by field type - you would have to loop through the individual fields within your scope and process them one at a time.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Ok thanks!

One more thing, if i loop through the individual field items, is there a way (syntax) to check if a field is a {mergefield} or if its a {formfield}?
 
Hi weeze2,

Check the Field Type ..

Code:
[blue]If [i]Field[/i].Type = wdFieldMergeField Then
    [green]' It is a MERGEFIELD
    ' etc.[/green]
End If[/blue]

For a full set of values see the Object Browser.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top