View Single Post
 
Old 09-25-2023, 08:54 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Default VBA macro to replace strings in italics with italics style

I'm trying to replace strings in italics with an italics style. This code returns an error and is incomplete:


Quote:
Sub ITALICS()
For Each myRng In ActiveDocument.StoryRanges
Do
With myRng
Do
With .Find
.MatchWildcards = False
.Text = ""
.Replacement.Text = ""
.Font.Italic
.Wrap = wdFindStop
.Execute
End With
If Find.Found Then
MsgBox Selection.Text
'Replace with Style
Else: Exit Do
End If
myRng.Collapse 0
Loop
End With
Set myRng = myRng.NextStoryRange
Loop Until myRng Is Nothing
Next myRng
End Sub
Reply With Quote