#1
|
|||
|
|||
Modify macro to only add bullets to highlighted text if it exists.
This macro works fine if before running it I highlight the text lines that I want to have bullets. It adds bullets to theses highlighted lines and then converts all of the text in this text box (including bulleted lines) to the desired font and size. I would like to change it so that if it happens that nothing is highlighted no bullets are added and it just moves on to converts all of the text in this text box to the desired font and size. What is happening now is, if nothing is highlighted it is adding one unwanted bullet at the beginning of all the text in my text box.
Code:
Sub Macro3() With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1) .NumberFormat = ChrW(61623) .TrailingCharacter = wdTrailingTab .NumberStyle = wdListNumberStyleBullet .NumberPosition = InchesToPoints(0.25) .Alignment = wdListLevelAlignLeft .TextPosition = InchesToPoints(0.5) .TabPosition = wdUndefined .ResetOnHigher = 0 .StartAt = 1 With .Font .Bold = wdUndefined .Italic = wdUndefined .StrikeThrough = wdUndefined .Subscript = wdUndefined .Superscript = wdUndefined .Shadow = wdUndefined .Outline = wdUndefined .Emboss = wdUndefined .Engrave = wdUndefined .AllCaps = wdUndefined .Hidden = wdUndefined .Underline = wdUndefined .Color = wdUndefined .Size = wdUndefined .Animation = wdUndefined .DoubleStrikeThrough = wdUndefined .Name = "Symbol" End With .LinkedStyle = "" End With ListGalleries(wdBulletGallery).ListTemplates(1).Name = "" Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _ ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:= _ False, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:= _ wdWord10ListBehavior Selection.WholeStory Selection.Font.Size = 18 End Sub |
#2
|
||||
|
||||
You really should be using styles to do this rather than applying local formatting. That said, there is a lot of extra steps needed to process multiple paragraphs of various styles so I'll take the easy way out for the sizing step.
Code that adapts to the selection size goes along the lines of Code:
Sub BulletsAndSizer() Dim aRng As Range Set aRng = Selection.Range If Len(aRng.Text) > 0 Then aRng.Style = "List Bullet" aRng.Expand Unit:=wdStory aRng.Font.Size = 18 End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Short, simple and seems to be everything I need. Thanks for the help.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro in Word to track colour of highlighted text | BABZ | Word VBA | 1 | 01-09-2017 10:33 PM |
I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? | AustinBrister | Word VBA | 8 | 05-28-2015 02:42 PM |
Add the same background image to every cell (text already exists). | TrixieWolf | Word Tables | 1 | 07-04-2014 01:06 PM |
Formatting- Apply changes to highlighted text results in same change to other text | sential | Word | 6 | 01-10-2014 03:22 PM |
Macro to mark non-coloured/non-highlighted text as hidden | PeterB | Word | 0 | 10-28-2009 07:54 AM |