Im am using Word VBA to create a form field and then insert a value into that field.
Problem is I need to change the data type of the field I have created.
Code:
ActiveDocument.Bookmarks("Loan_Amount").Select
ActiveDocument.FormFields.Add FFHere, wdFieldFormTextInput
ActiveDocument.FormFields("Text1").Result = Value
Had a hunt around but can't find anything on the topic. It would also be nice to change the name of the bookmark of the field (calls itself "Text1" by default).
It would also be nice to change the name of the bookmark of the field (calls itself "Text1" by default).
Like this?
Sub Sample()
Dim ff As FormField
ActiveDocument.Bookmarks("Loan_Amount").Select
Set ff = ActiveDocument.FormFields.Add(FFHere, wdFieldFormTextInput)
ff.Name = "BlahBlah"
End Sub
And here is an example which inserts a Text field but changes it to Date Field
Sub Sample()
Dim ff As FormField
Set ff = ActiveDocument.FormFields.Add(FFHere, wdFieldFormTextInput)
ff.Select
With Selection.FormFields(1)
'~~> Change Name Here
.Name = "BlahBlah"
'~~> Change Type here
With .TextInput
.EditType Type:=wdCurrentDateText, Default:="", Format:=""
.Width = 0
End With
End With
End Sub
Other type that you can change it to are
wdCurrentDateText
wdCalculationText
wdCurrentTimeText
wdDateText
wdNumberText
(This is what your question requested for) NOTE : I am assuming that FFHere
is a valid range
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.