#1
|
|||
|
|||
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" |
#2
|
||||
|
||||
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 |
#3
|
|||
|
|||
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. |
#4
|
||||
|
||||
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) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
||||
|
||||
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 |
#6
|
|||
|
|||
Hello, with all this I should be able to make something work here. Thanks for all the input.
|
|
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 |