Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 06-15-2016, 02:47 PM
Charles Kenyon Charles Kenyon is offline Form fields for text that is to be used later in the document Windows 8 Form fields for text that is to be used later in the document Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,536
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Not really. The thing is that Word puts things in layers or containers.

See the example given by Graham Mayor here: Installing Macros.

I believe that the following is the most thorough macro to do this that I've encountered. It comes from Greg Maxey in this thread.

Code:
Sub UpdateAllFieldsAllStoryMaxey()    ' Greg Maxey
    ' http://answers.microsoft.com/en-us/office/forum/office_2007-word/how-to-update-all-fields-in-a-document-at-once/54b43181-0ea7-4abc-bfb9-e0555125dfe5?page=5
    Dim rngStory As Word.Range
    Dim lngJunk As Long
    Dim oShp As Shape
    Dim oToc As TableOfContents, oToa As TableOfAuthorities, oTof As TableOfFigures
    lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType
    For Each rngStory In ActiveDocument.StoryRanges
      'Iterate through all linked stories
      Do
        On Error Resume Next
        rngStory.Fields.Update
        Select Case rngStory.StoryType
          Case 6, 7, 8, 9, 10, 11
            If rngStory.ShapeRange.Count > 0 Then
              For Each oShp In rngStory.ShapeRange
                If oShp.TextFrame.HasText Then
                   oShp.TextFrame.TextRange.Fields.Update
                End If
              Next
            End If
          Case Else
            'Do Nothing
        End Select
        On Error GoTo 0
        'Get next linked story (if any)
        Set rngStory = rngStory.NextStoryRange
      Loop Until rngStory Is Nothing
      'Special Cases
      For Each oToc In ActiveDocument.TablesOfContents
        oToc.Update
      Next oToc
      For Each oToa In ActiveDocument.TablesOfAuthorities
        oToa.Update
      Next
      For Each oTof In ActiveDocument.TablesOfFigures
        oTof.Update
      Next
    Next
End Sub
-
My experience, though, is that StyleRef fields update instantly when in a header or footer. I believe that this is true when they are in the body of a document as well but am not certain. I do know that they update much better than do REF fields.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Form fields for text that is to be used later in the document Creating a Form with Fields that will Populate into Another Document Mobius Word 3 05-06-2016 12:46 AM
Macro to keep formatted form fields after mail merge or replace text with formatted form fields jer85 Word VBA 2 04-05-2015 10:00 PM
Form fields for text that is to be used later in the document Multiple Text Fields in Form robstark Word 1 08-11-2014 11:26 AM
Extract form fields to Word Document RonNCmale Word VBA 22 01-11-2014 05:06 AM
Form fields for text that is to be used later in the document Form Fields - Create blank form text field with if statement? LAssist2011 Word 5 12-14-2011 03:02 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft