MailMergeFields.AddAsk method (Word)

Adds an ASK field to a mail merge main document. Returns a MailMergeField object.

Syntax

expression. AddAsk( _Range_ , _Name_ , _Prompt_ , _DefaultAskText_ , _AskOnce_ )

expression Required. A variable that represents a 'MailMergeFields' collection.

Parameters

Name Required/Optional Data type Description
Range Required Range object The location for the ASK field.
Name Required String The bookmark name that the response or default text is assigned to. Use a REF field with the bookmark name to display the result in a document.
Prompt Optional Variant The text that's displayed in the dialog box.
DefaultAskText Optional Variant The default response, which appears in the text box when the dialog box is displayed. Corresponds to the \d switch for an ASK field.
AskOnce Optional Variant True to display the dialog box only once instead of each time a new record is merged. Corresponds to the \o switch for an ASK field.

Return value

MailMergeField

Remarks

When updated, an ASK field displays a dialog box that prompts you for text to assign to the specified bookmark.

Example

This example adds an ASK field at the end of the active mail merge main document.

Dim rngTemp As Range 
 
Set rngTemp = ActiveDocument.Content 
 
rngTemp.Collapse Direction:=wdCollapseEnd 
ActiveDocument.MailMerge.Fields.AddAsk _ 
 Range:=rngTemp, _ 
 Prompt:="Type your company name", _ 
 Name:="company", AskOnce:=True

This example adds an ASK field after the last mail merge field in Main.doc.

Dim colMailMergeFields As Object 
Dim rngTemp As Range 
 
Set colMailMergeFields = Documents("Main.doc").MailMerge.Fields 
 
colMailMergeFields(colMailMergeFields.Count).Select 
 
Set rngTemp = Selection.Range 
 
rngTemp.Collapse wdCollapseEnd 
colMailMergeFields.AddAsk Range:=rngTemp, Name:="name", _ 
 Prompt:="What is your name"

See also

MailMergeFields Collection Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.