View Single Post
 
Old 09-23-2023, 03:38 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Question VBA Quotes Before Punctuation

I am trying to move quotes before punctuation with a Word macro, but apart from an error in the code here below, I cannot find a way to swap characters without using 'Selection.' Can someone help? Thanks! Here's the code:


Quote:
'VBA Quotes Before Punctuation
Application.ScreenUpdating = False
Dim myRng As Word.Range, myChr
For Each myRng In ActiveDocument.StoryRanges 'Text and Footnotes
Do
For Each myChr In myRng.Characters
If myChr.Text Like "[,;.:?]" _
And myChr.First.Next.Text Like "[«‹›»" & Chr(39) & Chr(34) & Chr(146) & Chr(148) & "]" Then
'Revert without using "Selection."
End If
Next
Set myRange = myRange.NextStoryRange
Loop Until myRange Is Nothing
Next

Last edited by RobiNew; 09-23-2023 at 07:24 AM. Reason: typo
Reply With Quote