PDA

View Full Version : Adding wdFieldFormTextInput



jthomp1
12-13-2011, 01:21 PM
I'm trying to add a Form Field with the following properties:

Form Field Type: TextInput
TextFormFieldType: wdNumberText
Number Format: $#,##0
Name: fld_Est_Receipts

Here's my code so far:


Selection.FormFields.Add Range:=Selection.Range, _
Type:=wdFieldFormTextInput, _
TextFormFieldType:=wdNumberText, _
Format:="$#,##0", _
Name:="fld_Est_Receipts"


Problem:
Getting Compile Error:
Named argument not found

at the TestFormFieldType:=

Question:
How do I properly set the number type, number format and name properties?

gmaxey
12-13-2011, 02:20 PM
TextInput.Type is a "read" only property so you can't set it using VBA.

What you can do is use the dialog programatically to set properties:
Sub ScratchMacro()
Dim oFF As FormField
Set oFF = ActiveDocument.FormFields.Add(Selection.Range, wdFieldFormTextInput)
With Dialogs(wdDialogFormFieldOptions)
.TextType = wdNumberText
.Name = "fld_Est_Receipts"
.TextFormat = "$#,##0"
.Execute
End With
End Sub

jthomp1
12-13-2011, 03:27 PM
Your solution worked beautifully, Greg. Thanks very much.