Member_2_8045560
asked on
Find and replace other than given style
Dear All,
This is Iliyas, I have this query, i.e., in word document I have style named 'F-Caption' and other styles. I need to find and replace other than the style 'F-Caption' (should not find in the text with style 'F-Caption'). I'm looking for your quick reply. Thanks in advance.
This is Iliyas, I have this query, i.e., in word document I have style named 'F-Caption' and other styles. I need to find and replace other than the style 'F-Caption' (should not find in the text with style 'F-Caption'). I'm looking for your quick reply. Thanks in advance.
ASKER
Thank you for your effort, but I don't want to replace the style instead I want to replace text
Hi,
Share sample of the word file and let me know what do you need to replace with what?
Share sample of the word file and let me know what do you need to replace with what?
ASKER
Hi
In the attached document, should replace "p." into "S." except the text with style "Float-Caption".
Thanks in advance.
329063_0_En_31-1_Chapter.DOCX
In the attached document, should replace "p." into "S." except the text with style "Float-Caption".
Thanks in advance.
329063_0_En_31-1_Chapter.DOCX
Hi,
pls try
pls try
Sub Macro()
Dim r As Range
Set r = ActiveDocument.Range
With r.Find
Do While .Execute(Findtext:="p.", Forward:=True) = True
If r.Style.NameLocal <> "Float-Caption" Then
r.Text = "S."
r.Collapse 0
End If
Loop
End With
End Sub
Regards
ASKER
Tried but loops continuously
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow thanks, it does the trick.
Solution according to author's comment
Check this code
Sub FindAndChangeStyle()
Dim i As Paragraph
'Find Normal style and format it to be Heading 1 style
For Each i In ActiveDocument.Paragraphs
If i.Style.NameLocal = "Normal" And Len(i.Range.Text) > 1 Then
i.Range.Style = ActiveDocument.Styles("Hea
End If
Next
End Sub