Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-21-2021, 08:28 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,529
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

Using a macro to replace text where ever it appears in a document including Headers, Footers, Textboxes, etc.
Reply With Quote
  #2  
Old 10-21-2021, 01:19 PM
laith93 laith93 is offline Putting parentheses around sequence number of caption label Windows 10 Putting parentheses around sequence number of caption label Office 2019
Competent Performer
Putting parentheses around sequence number of caption label
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default

Thank you MR. Charles
Again the above macros work to find and replace normal text anywhere, but do not look for the text of field codes ex: {Seq Appendix \* Arabic}.
Here the sample file you can try to explore what I mean.
Attached Files
File Type: docx Sample.docx (190.1 KB, 12 views)

Last edited by laith93; 10-21-2021 at 09:25 PM.
Reply With Quote
  #3  
Old 10-21-2021, 05:39 PM
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,529
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

Quote:
Originally Posted by laith93 View Post
Thank you MR. Charles
Again the above macros work to find and replace normal text anywhere, but do not look for the text of field codes ex: {Seq Appendix \* Arabic}.
Here the sample file you can try to explore what I mean.
That page shows how to loop through stories in a document to get to all parts.


Code:
Sub AppendixParens()
'   Charles Kenyon using code from Graham Mayor
'   October 21, 2021
'   https://www.msofficeforums.com/word/47835-putting-parentheses-around-sequence-number-caption-label.html
    Dim oStory As range, oFld as Field
    On Error Resume Next
    For Each oStory In ActiveDocument.StoryRanges
        Do
            For Each oFld In oStory.Fields
                If oFld.Type = wdFieldSequence Then
                    If InStr(1, oFld.Code, "Appendix") > 0 Then
                        oFld.Result.InsertAfter ")"
                        oFld.Result.InsertBefore "("
                    End If
                End If
            Next oFld
        Loop Until oStory Is Nothing
     Next
    Set oFld = Nothing
    Set oStory = Nothing
    On Error GoTo -1
 End Sub
Reply With Quote
  #4  
Old 10-21-2021, 07:42 PM
laith93 laith93 is offline Putting parentheses around sequence number of caption label Windows 10 Putting parentheses around sequence number of caption label Office 2019
Competent Performer
Putting parentheses around sequence number of caption label
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
Sub AppendixParens()
Thank you again, Mr. Charles
I applied your code on my sample file, as it contains only two caption
It takes about 15 mins without any changes until an error message appears "Not responding"
05.png
My laptop RAM is almost full, and fan speed was increased, although I have a laptop with (CPU Intel Core i7, RAM 8GB, GPU 2GB).
Any recommendation, please?
Reply With Quote
Reply

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 02:47 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