Hello People,
I have written a macro to correct some basic syntax errors in form fields used in a large number of documents. Another macro ensures that this one is run on each document in a given folder. This macro will check through the document for specific known errors in the default text of the form fields and will replace these with known corrections. Here is the macro:
Sub CorrectDefaultText(WdDoc As Document)
Dim oFrmFlds As FormFields
Dim pIndex As Long
Dim iFFs As Integer
Dim strName As String
'all the Form Fields in the document
Set oFrmFlds = ActiveDocument.FormFields
'the number of Form Fields in the document
iFFs = oFrmFlds.Count
'run through each form field
For pIndex = 1 To iFFs
oFrmFlds(pIndex).Select
'test the default text for syntax / spelling errors and inconsistencies
Select Case oFrmFlds(pIndex).TextInput.Default
Case "Adressee Adr1"
oFrmFlds(pIndex).TextInput.Default = "Addressee Adr1"
Case "Adressee Adr2"
oFrmFlds(pIndex).TextInput.Default = "Addressee Adr2"
Case "Adressee Adr3"
oFrmFlds(pIndex).TextInput.Default = "Addressee Adr3"
Case "Adressee Adr4"
oFrmFlds(pIndex).TextInput.Default = "Addressee Adr4"
Case "Adressee Postcode"
oFrmFlds(pIndex).TextInput.Default = "Addressee Postcode"
Case "Commercial Name"
oFrmFlds(pIndex).TextInput.Default = "Product Name"
Case "Product"
oFrmFlds(pIndex).TextInput.Default = "Product Name"
Case "ref"
oFrmFlds(pIndex).TextInput.Default = "Ref"
Case "Branded Policy email"
oFrmFlds(pIndex).TextInput.Default = "Branded Policy Email"
Case "Destination"
oFrmFlds(pIndex).TextInput.Default = "Claim Country"
Case "Branded Policy Name"
oFrmFlds(pIndex).TextInput.Default = "Branded Policy Adr1"
End Select
Next pIndex
End Sub
Well that's all fine, it works and no bugs etc. However, you can't see that it has worked until you double click on each form field and then click "OK" So the default text is not displayed until then. How can I force Word to update the displayed text to match the newly changed default text?
Thanks for your time and I am of course willing to answer more questions if anything does not seem to make sense to you
I have written a macro to correct some basic syntax errors in form fields used in a large number of documents. Another macro ensures that this one is run on each document in a given folder. This macro will check through the document for specific known errors in the default text of the form fields and will replace these with known corrections. Here is the macro:
Sub CorrectDefaultText(WdDoc As Document)
Dim oFrmFlds As FormFields
Dim pIndex As Long
Dim iFFs As Integer
Dim strName As String
'all the Form Fields in the document
Set oFrmFlds = ActiveDocument.FormFields
'the number of Form Fields in the document
iFFs = oFrmFlds.Count
'run through each form field
For pIndex = 1 To iFFs
oFrmFlds(pIndex).Select
'test the default text for syntax / spelling errors and inconsistencies
Select Case oFrmFlds(pIndex).TextInput.Default
Case "Adressee Adr1"
oFrmFlds(pIndex).TextInput.Default = "Addressee Adr1"
Case "Adressee Adr2"
oFrmFlds(pIndex).TextInput.Default = "Addressee Adr2"
Case "Adressee Adr3"
oFrmFlds(pIndex).TextInput.Default = "Addressee Adr3"
Case "Adressee Adr4"
oFrmFlds(pIndex).TextInput.Default = "Addressee Adr4"
Case "Adressee Postcode"
oFrmFlds(pIndex).TextInput.Default = "Addressee Postcode"
Case "Commercial Name"
oFrmFlds(pIndex).TextInput.Default = "Product Name"
Case "Product"
oFrmFlds(pIndex).TextInput.Default = "Product Name"
Case "ref"
oFrmFlds(pIndex).TextInput.Default = "Ref"
Case "Branded Policy email"
oFrmFlds(pIndex).TextInput.Default = "Branded Policy Email"
Case "Destination"
oFrmFlds(pIndex).TextInput.Default = "Claim Country"
Case "Branded Policy Name"
oFrmFlds(pIndex).TextInput.Default = "Branded Policy Adr1"
End Select
Next pIndex
End Sub
Well that's all fine, it works and no bugs etc. However, you can't see that it has worked until you double click on each form field and then click "OK" So the default text is not displayed until then. How can I force Word to update the displayed text to match the newly changed default text?
Thanks for your time and I am of course willing to answer more questions if anything does not seem to make sense to you