|
-
May 19th, 2010, 08:12 AM
#1
Thread Starter
Lively Member
[RESOLVED] Footer field update...
Hi, Yep it's me again... sorry
We've had a few issues with different docs that contain fields, and those fields becoming blank after our previous code updates, so we wrote a new code that omits some drops down and input fields, so it doesn't update all.
The only prob is, the below code now update the fields but not the one we originally set out to update, The footer field. I've been at it a few hours now and can't seem to get it to work without it updating all fields, which we don't want to do. any help would be greatly appreciated.
Code:
Sub UpdateDocFields()
Dim iCount As Integer
Dim aField As Field
Dim DocProtect As Boolean
' If protected; unprotect document
If ActiveDocument.ProtectionType <> wdNoProtection Then
DocProtect = True
ActiveDocument.Unprotect
End If
' Loop through all text form fields in the document.
For Each aField In ActiveDocument.Fields
'If the form field is a text form OR drop down field...
If aField.Type = wdFieldFormTextInput Or aField.Type = wdFieldFormDropDown Then
'do nothing with FormText field
'MsgBox "Field not updated!" 'TEST MESSAGE ONLY - REMOVE FROM LIVE
Else
aField.Update
ActiveDocument.StoryRanges(wdPrimaryFooterStory).Fields.Update
aField.Update
'MsgBox "Field updated!" 'TEST MESSAGE ONLY - REMOVE FROM LIVE
End If
' Increment icount
iCount = iCount + 1
Next aField
'if document was originally protected, then re-protect
If DocProtect = True Then
ActiveDocument.Protect Password:="", NoReset:=True, Type:=wdAllowOnlyFormFields
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|