Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unbold all text where text is in a alpha/numeric or bullet list in Word 2013 1

Status
Not open for further replies.

sxschech

Technical User
Jul 11, 2002
1,033
US
Would like to figure out how to remove bold from text (unbold) within a list and leave bolded text elsewhere as is.

I found this code which seems to show the type of list [tt]Selection.Range.ListFormat.ListType[/tt] and that showed the list type as 3, when I put into vba after trial and error it intellisensed as wdListSimpleNumbering. I am not so familiar with word vba. I had found an example with style, but since the code was mentioning listformat and listtype, it errored out when I tried to use that in the style example. "Can't assign to a read only property".

BEFORE...
[pre]
This is a bolded sentence that should remain bold.

1. This is the first question?
a. This is an answer
b. This is the correct answer
c. This is another answer
d. All of the above
[/pre]

AFTER...
[pre]
This is a bolded sentence that should remain bold.

1. This is the first question?
a. This is an answer
b. This is the correct answer
c. This is another answer
d. All of the above
[/pre]


Code:
Sub RemoveBoldFromBulletList()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

With Selection.Find
    Selection.Range.[highlight #FCE94F]ListFormat.ListType = 3[/highlight]
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
End With
Selection.Find.Execute
'Selection.Find.Execute Replace:=wdReplaceAll
Selection.Font.Bold = False








 
Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Text = ""
  .Font.Bold = True
  .Style = "List Paragraph"
  With .Replacement
    .ClearFormatting
    .Text = ""
    .Font.Bold = False
  End With
  .Format = True
  .Forward = True
  .Wrap = wdFindContinue
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub

Cheers
Paul Edstein
[MS MVP - Word]
 
Hi Paul,

I pasted your code and so far doesn't seem to make any changes to the document. I also tried highlighting the entire document (Ctrl+A) before running the code and still no change. I stepped through the code and it went through all the lines without error.
 
The code assumes your numbering uses Word's default "List Paragraph" Style, which your document evidently doesn't use for this. Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .Font.Bold = True
    .Execute
  End With
  Do While .Find.Found
    If .ListFormat.ListType = 3 Then .Font.Bold = False
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub

Cheers
Paul Edstein
[MS MVP - Word]
 
That seems to have worked perfectly. Thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top