Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2024, 09:17 AM
Shelley Lou Shelley Lou is offline VBA Adding missing Punctuation to end of Paragraphs Windows 10 VBA Adding missing Punctuation to end of Paragraphs Office 2016
Expert
VBA Adding missing Punctuation to end of Paragraphs
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA Adding missing Punctuation to end of Paragraphs

Hi Andrew, that is an excellent idea of looking for the duplication instances after the code has run. The below looks for instances of ;]; or .]. and removes the duplicate punctuation after the square bracket to be ;] or .] - this works well but only if the square bracket is not within a text form field. I'm not sure what to add to the code to look for if the square bracket is within a text form field.



Code:
Sub RemovePuncDemo1()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchWildcards = True
    .text = "([;.])([\]])([;.])"
    .Replacement.text = "\1\2"
    .Execute Replace:=wdReplaceAll
    End With
End Sub
Capture.JPG
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA help with punctuation code Shelley Lou Word VBA 0 12-09-2022 05:39 AM
Adding punctuation to body of text Sweetpea7 Word 5 08-29-2021 07:44 PM
VBA Adding missing Punctuation to end of Paragraphs punctuation order fariz Word 2 10-31-2016 12:57 AM
Punctuation lexsper Word 0 04-06-2015 07:26 AM
VBA Adding missing Punctuation to end of Paragraphs Paragraph border missing on interior paragraphs strathglass Word 1 09-19-2011 02:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:57 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