Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-30-2018, 04:24 PM
14spar15 14spar15 is offline Modify macro to only add bullets to highlighted text if it exists. Windows XP Modify macro to only add bullets to highlighted text if it exists. Office 2000
Advanced Beginner
Modify macro to only add bullets to highlighted text if it exists.
 
Join Date: Mar 2011
Posts: 97
14spar15 is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 10-30-2018, 06:54 PM
Guessed's Avatar
Guessed Guessed is offline Modify macro to only add bullets to highlighted text if it exists. Windows 10 Modify macro to only add bullets to highlighted text if it exists. Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #3  
Old 10-30-2018, 08:27 PM
14spar15 14spar15 is offline Modify macro to only add bullets to highlighted text if it exists. Windows 7 64bit Modify macro to only add bullets to highlighted text if it exists. Office 2010 64bit
Advanced Beginner
Modify macro to only add bullets to highlighted text if it exists.
 
Join Date: Mar 2011
Posts: 97
14spar15 is on a distinguished road
Default

Short, simple and seems to be everything I need. Thanks for the help.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Modify macro to only add bullets to highlighted text if it exists. Macro in Word to track colour of highlighted text BABZ Word VBA 1 01-09-2017 10:33 PM
Modify macro to only add bullets to highlighted text if it exists. 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
Modify macro to only add bullets to highlighted text if it exists. 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:44 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft