Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 12-13-2018, 07:16 AM
14spar15 14spar15 is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Mar 2011
Posts: 41
14spar15 is on a distinguished road
Default Change macro to only use large bullets

Hello, I have this text box that after all the text has been entered I run this macro. The text is entered by pasting from other various sources. Before running the macro I will highlight lines that I want bullets added to. Everything works fine except for certain cases where text is pasted that already has bullets. The problem is when the macro runs the large bullets (that I want and were pasted with the text) become small little dot bullets. Note: Being that these lines already started with bullets they are not highlighted before running the macro. Is there way to change this macro so that the bullets will always be the larger dots and not the smaller? Thanks

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
  aRng.Font.Name = "Times New Roman"

Reply With Quote
  #2  
Old 12-13-2018, 03:28 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 1,166
Guessed has a spectacular aura aboutGuessed has a spectacular aura aboutGuessed has a spectacular aura about
Default

You should be doing this with styles. Set the property of the List Bullet style so that its bullets are the size you want. While you are at it, make the styles font 18pt and Times New Roman.

When you then expand the aRng to the story, what is the style of the other bulleted paragraphs (the ones that weren't in the original selection)? If they should also have List Bullet applied then do that. If they are some other style, change the style definition on them to match the attributes you want to see.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 12-15-2018, 06:50 AM
14spar15 14spar15 is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Mar 2011
Posts: 41
14spar15 is on a distinguished road
Default

Thank you for the response here. Iíve have never used Microsoft Word styles before so I have done some research on them but Iím still having problems here. Iím not sure if your solution was meant to just replace running this macro are not. It seems that the styles are based more on individual paragraphs. Hereís an example of what might be in the text box Iím applying this macro to.


This is where I will be going for this yearís vacation.

Las Vegas
Hoover dam

I will be taking this vacation sometime in the spring before it starts getting too hot.


Iím using some script here so the macro will always be applied to the text box regardless of its content.
The macro is working fine in these cases.
1. In the above case I would highlight Las Vegas and Hoover Dam and then run the script that would run the macro that would add bullets (large like I want) and set the font for the entire text box.
2. If I manually add the bullets and run the macro everything works fine. I just make sure when the macro is run that nothing is highlighted in the text box.
3. If I do not want any bullets and I run the macro everything works fine. Again I just make sure that nothing is highlighted when the macro is run.

The problem is if I copy some text from another source that already has bullets (that appear to be a large) and run the macro (nothing is highlighted) quite often the resulting bullets are just small little dots and I always want my normal large ones.
Reply With Quote
  #4  
Old 12-15-2018, 10:54 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,755
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice
Default

While it would be preferable, as Andrew suggests, to use styles for the body and bullet paragraphs, your macro will do what you require if you add code to reset the paragraph format and font of the pasted text.

Note also that as this works with paragraphs, you will get some odd results if you paste text that has line breaks rather than paragraph breaks e.g. pasting from your message example.
Code:
Sub BulletsAndSizer()
Dim aRng As Range
    Set aRng = Selection.Range
    aRng.Text = Replace(aRng.Text, Chr(11), Chr(13))
    If Len(aRng.Text) > 0 Then aRng.Style = "List Bullet"
    With aRng
        .Expand Unit:=wdStory
        .Font.Reset
        .ParagraphFormat.Reset
        .Font.Size = 18
        .Font.Name = "Times New Roman"
    End With
    Set aRng = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 12-16-2018, 03:57 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 1,166
Guessed has a spectacular aura aboutGuessed has a spectacular aura aboutGuessed has a spectacular aura about
Default

And doing it with styles, it would be like this. The first half wouldn't actually need to run every time. Once the document styles are configured that part wouldn't need to be used again.
Code:
Sub BulletsAndSizer()  
  With ActiveDocument.Styles("Normal").Font
    .Size = 18
    .Name = "Times New Roman"
  End With
  With ActiveDocument.Styles("List Bullet")
    .Font.Size = 18
    .Font.Name = "Times New Roman"
    .ListTemplate.ListLevels(1).Font.Size = 40
  End With
  
  Dim aRng As Range
  Set aRng = Selection.Range
  aRng.Expand Unit:=wdStory
  aRng.Style = "Normal"
  Set aRng = Selection.Range
  aRng.Style = "List Bullet"
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #6  
Old 12-20-2018, 08:06 AM
14spar15 14spar15 is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Mar 2011
Posts: 41
14spar15 is on a distinguished road
Default

Hello, with all this I should be able to make something work here. Thanks for all the input.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change default bullets settings in Word 2016? kevinbradley57 Word 4 10-05-2018 09:50 AM
Bullets automatically change values AllenWalker Word 4 07-18-2018 06:43 AM
How do I get bullets and text to change color together? jborchel PowerPoint 0 12-05-2012 03:16 PM
Change color of text in bullets franklyorange PowerPoint 2 06-22-2010 04:51 AM
Is there a way to change the header in a large amount of documents at one time? ntsstaffing Word 1 07-11-2009 12:12 PM


All times are GMT -7. The time now is 11:46 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft