Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey Community,
i use this macro
26. To reset InputField values
Sub ResetInputField
' Reset the InputField
set fld = ActiveDocument.Fields("InputFieldName")
fld.ResetInputFieldValues 0, 0 ' 0 = All values reset, 1 = Reset Possible value, 2 = Reset single value
End Sub
My Question is how can i rest more then one field ?
And in one button to rest all my field to the last data from DB
Thank
Like attached.?
It may be easier to remove all the data using the Reduce Data -> Remove All Values option from the File menu and then reload the document like I mentioned in this post: Re: InputField.
If you insist on macro's then you need to loop through a list of field names and call the ResetInputField subroutine with each field name as a parameter. Perhaps something like this:
Sub ResetInputField(strFieldName)
set fld = ActiveDocument.Fields(strFieldName)
fld.ResetInputFieldValues 0, 0
End Sub
Sub ResetAllInputFields
set flds = ActiveDocument.GetFieldDescriptions
for i = 0 to flds.Count - 1
set fld = flds.Item(i)
if fld.IsInputField then ResetInputField(fld.Name)
next
End Sub
Thank you again for you help, my client didn't want the first solution you gave me, the request is on button that will rest all my input field
On your macro i can use only one field (in my pic i have mroe then one, mark in yellow )
Sub ResetInputField(strFieldName)
set fld = ActiveDocument.Fields(strFieldName)
fld.ResetInputFieldValues 0, 0
End Sub
set flds = ActiveDocument.GetFieldDescriptions
for i = 0 to flds.Count - 1
set fld = flds.Item(i)
if fld.IsInputField then ResetInputField(fld.Name)
next
Hi David,
You can use below macro to reset all the input fields in single click. Attached sample for your reference.
Sub ResetInputField
fldArray= Array("Budget","Status","Date") // Your input field names
For i=0 to UBound(fldArray)
set fld = ActiveDocument.Fields(fldArray(i))
fld.ResetInputFieldValues 0, 0 ' 0 = All values reset, 1 = Reset Possible value, 2 = Reset single value
Next
End Sub
Then you're executing the wrong sub with your button.
its work but when i do reload it failed
I use only one sub
Sub ResetInputField(strFieldName)
set fld = ActiveDocument.Fields(strFieldName)
fld.ResetInputFieldValues 0, 0
End Sub
Sub ResetAllInputFields
set flds = ActiveDocument.GetFieldDescriptions
for i = 0 to flds.Count - 1
set fld = flds.Item(i)
if fld.IsInputField then ResetInputField(fld.Name)
next
End Sub
There is something wrong in your load script. The above macro is not related with the load script. You can check the log file to identify the issue.
Like attached.?