Share via

Document Reformatting

Jay Dunn 0 Reputation points
2026-02-24T18:03:09.21+00:00

I have developed some vba code to perform formatting changes to a document. It goes through and updates the paragraph formatting of various paragraph styles such as normal and caption. Now the styles update just fine but in the case of the captions I run into a problem. While the style itself updates, the actual captions themselves don't. I can then manually format each caption and it will update correctly but I was hoping that this could be done in the vba code. Any suggestions?

Jay Dunn

Microsoft 365 and Office | Word | For business | Windows
{count} votes

2 answers

Sort by: Most helpful
  1. Jay Freedman 207.2K Reputation points Volunteer Moderator
    2026-02-24T20:32:42.3+00:00

    The AI is hallucinating again. Word does not treat captions as fields.

    Captions that are created by the Insert Caption dialog will contain a field, a SEQ or sequence field, that displays the sequence number of the figure, table, or other object. However, that field has nothing to do with the font or paragraph formatting of the caption.

    2 people found this answer helpful.
    0 comments No comments

  2. Q&A Assist
    2026-02-24T18:03:17.0233333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To ensure that the captions update correctly in your VBA code, you can try forcing a refresh of the fields after updating the styles. Captions in Word are often treated as fields, and sometimes they do not automatically refresh when the style changes. You can use the following VBA code snippet to update all fields in the document after you have made your style changes:

    Sub UpdateCaptions()
        Dim fld As Field
        ' Update all fields in the active document
        For Each fld In ActiveDocument.Fields
            fld.Update
        Next fld
    End Sub
    

    Call this UpdateCaptions subroutine after you have updated your paragraph styles to ensure that all captions reflect the new formatting. This should help automate the process and eliminate the need for manual updates.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.