Results 1 to 6 of 6

Thread: [RESOLVED] Word 2003 Update field issue

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Resolved [RESOLVED] Word 2003 Update field issue

    Hi all,

    I've had a few users complain about opening docs with cross ref/table of content links. When we recieve docs with them, the below code checks them and goes nuts and tries to repaginate and gets stuck in a loop, till the doc crashes. The code below updates fields except 'formtextinput and 'dropdown' as the update code refreshes/blanks them, which is a nightmare for forms that are submitted to us from other staff.

    Is there a way to omit table of content / cross references but still update fieldcodes such as file path fields inputted into a footer?

    Code:
    Sub UpdateDocumentFooter()
                                ''SECOND ATTEMPT CODE
        Dim iCount As Integer, DocProtect As Boolean
    
        '~~> If protected, unprotect document
        If ActiveDocument.ProtectionType <> wdNoProtection Then
            ActiveDocument.Unprotect
            DocProtect = True
        End If
    
        '~~> Prevent Screen Flickering
        Application.ScreenUpdating = False
    
        '~~> move selection to end of document
        Selection.EndKey wdStory
    
        ActiveDocument.Sections(ActiveDocument.Sections.Count) _
        .Footers(1).Range.Fields.Update
    
        Application.ScreenUpdating = True
    
        '~~> If document was originally protected, then re-protect
        If DocProtect = True Then
            ActiveDocument.Protect Password:="", NoReset:=True, _
            Type:=wdAllowOnlyFormFields
        End If
    End Sub
    
    
    Sub UpdateDocFields()
      
    Dim iCount As Integer
    Dim aField As Field
    Dim DocProtect As Boolean
    
    'On Error GoTo ErrHandler
    
    ' 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
            '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
    
    'ErrHandler:
    End Sub
    *Edit
    Forgot to mention the ToC's that cause the issue are from docs of quite some size, 15 pages or more.
    Last edited by Kubull; Jun 2nd, 2010 at 10:43 AM.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Word 2003 Update field issue

    May I see a sample?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Re: Word 2003 Update field issue

    Sure, Please see the attached.

    I couldn't upload my normal(template) Darn Work restrictions. but just running the above script will lock the attached.

    I've recreated the doc I initially had problems with, in doing so helped me find out why the issue is happening, We recieve alot of document like this, Where hyper links aren't working or the TOC is amended to suit the author and not the dynamics of the field updates.

    Many thanks for your help CoolSid :0)
    Attached Files Attached Files

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Re: Word 2003 Update field issue

    Not to Worry Sid, I cleaned up our global template, and instructed our secretaries to avoid this kind of issue, so all is well. Thanks for your input anyways

  5. #5
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Word 2003 Update field issue

    Hmmm... How did I miss this thread?

    Glad it is sorted...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Re: [RESOLVED] Word 2003 Update field issue

    not to worry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width