![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#5
|
||||
|
||||
|
Greg's posted one way, here's another:
Code:
Sub Demo()
Application.ScreenUpdating = False
ActiveWindow.View.ShowFieldCodes = True
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "Section ^d"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
Do While .Find.Found
With .Fields(1)
With .Code
If InStr(.Text, "Mergeformat") > 0 Then
.Text = Replace(.Text, "Mergeformat", "Charformat")
ElseIf InStr(.Text, "Charformat") = 0 Then
.InsertAfter " \* Charformat"
End If
.Words.First.Next.Style = "Emphasis"
End With
.Update
End With
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
ActiveWindow.View.ShowFieldCodes = False
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
VBA Code to Insert Legacy Text Field
|
PSSMargaret | Word VBA | 17 | 06-15-2016 04:22 AM |
Variable text field code based on occurrences on each page
|
Cosmo | Word | 2 | 12-29-2015 11:54 AM |
| Macro to select an { includepicture } field code and format the picture behind text and 100% scale | sanpedro | Word VBA | 3 | 03-30-2015 10:50 PM |
| need an arbitrary field code | ajetrumpet | Word | 1 | 07-15-2013 04:58 PM |
| field code question | bordercollie10 | Mail Merge | 3 | 10-15-2009 07:55 AM |