Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #20  
Old 10-22-2021, 04:42 AM
Charles Kenyon Charles Kenyon is offline Putting parentheses around sequence number of caption label Windows 10 Putting parentheses around sequence number of caption label Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,530
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

Andrew, I ran your macro on the sample file provided and it did nothing because of the term "Table." When I changed it to "Appendix" it caught the in-line instance but not the one in the Textbox.


Code:
Sub AppendixParensIntegrated()
'   Charles Kenyon and Andrew Lockton using code from Graham Mayor
'   October 21, 2021
'   https://www.msofficeforums.com/word/47835-putting-parentheses-around-sequence-number-caption-label.html
'   Instead of adding () characters, change the field's display format to include them
    Dim oStory As range, oFld As Field, iCount As Integer, aRng As range
    On Error Resume Next
      For Each oStory In ActiveDocument.StoryRanges
        For Each oFld In oStory.Fields
          If oFld.Type = wdFieldSequence Then
            If oFld.Code Like "*Appendix*" Then
              oFld.Code.Text = "SEQ Appendix \# ""(#)"" "
              iCount = iCount + 1
            End If
          End If
        Next oFld
      Next oStory
      ActiveDocument.Fields.Update
    Set oFld = Nothing
    Set oStory = Nothing
    On Error GoTo 0
    MsgBox iCount & " instances bracketed.", vbOKOnly, "Macro complete"
End Sub
Reply With Quote
 

Tags
find & replace, find replace;wildcards, word 19



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula for number sequence 14spar15 Excel Programming 4 03-18-2018 07:00 PM
Putting parentheses around sequence number of caption label Assigning a string variable to a userform label caption Larry_1 Excel Programming 3 12-18-2017 06:59 AM
Putting parentheses around sequence number of caption label how to have two formats in the Caption style: Label – number - text? Jamal NUMAN Word 39 03-14-2017 06:32 PM
Putting parentheses around sequence number of caption label Custom caption list label lost in a new Word session New Daddy Word 1 09-22-2013 09:21 AM
Custom caption label annoyance zac Word 1 08-29-2010 09:56 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:34 PM.


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