View Single Post
 
Old 09-16-2018, 01:24 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The code from my web site should work in a text box ... and certainly does here. However it may not work if the text box is located in a header/footer in which case you need more brute force to update it e.g.


Code:
Sub UpdateAllFields()
Dim oStory As Range
    For Each oStory In ActiveDocument.StoryRanges
        oStory.Fields.Update
        If oStory.StoryType <> wdMainTextStory Then
            While Not (oStory.NextStoryRange Is Nothing)
                Set oStory = oStory.NextStoryRange
                oStory.Fields.Update
            Wend
        End If
    Next oStory
    UpdateFieldsAnotherWay
    Set oStory = Nothing
lbl_Exit:
    Exit Sub
End Sub

Sub UpdateFieldsAnotherWay()
Dim sView As String
Dim sUpdate As String
    sView = ActiveDocument.ActiveWindow.View.Type
    sUpdate = Options.UpdateFieldsAtPrint
    Options.UpdateFieldsAtPrint = True
    Application.ScreenUpdating = False
    PrintPreview = True
    PrintPreview = False
    ActiveDocument.ActiveWindow.View.Type = sView
    Options.UpdateFieldsAtPrint = sUpdate
    Application.ScreenUpdating = True
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote