SuperDocT
04-17-2023, 10:12 PM
Hi, I look for the correct Macro Code in order to search into the whole document for a certain code and turn the whole line into heading 6
I precise that the line containing the code can be in any format (heading/normal etc...)
This is the code I wrote and obviously doesn't work:
Sub head6_to_heading()
Dim doc As Word.Document
Dim rng As Word.Range
Set doc = ActiveDocument
Set rng = doc.Content
With rng.Find
.Text = "(head-"
.MatchCase = False
.MatchWholeWord = False
.Replacement.Style = doc.Styles("Heading 6").ParagraphFormat
.Wrap = wdFindStop
End With
End Sub
Thanks by advance
I precise that the line containing the code can be in any format (heading/normal etc...)
This is the code I wrote and obviously doesn't work:
Sub head6_to_heading()
Dim doc As Word.Document
Dim rng As Word.Range
Set doc = ActiveDocument
Set rng = doc.Content
With rng.Find
.Text = "(head-"
.MatchCase = False
.MatchWholeWord = False
.Replacement.Style = doc.Styles("Heading 6").ParagraphFormat
.Wrap = wdFindStop
End With
End Sub
Thanks by advance