VBA:Make Font, Size, Numbered List Same Format (Arial 11)
-
- 3StarLounger
- Posts: 240
- Joined: 17 Feb 2022, 05:16
VBA:Make Font, Size, Numbered List Same Format (Arial 11)
hi expert..
I am looking for VBA code in MS Word to make numbered list (bullet & numbering) in a Word document same font & same font size
often, when select all document then change font & size for NUMBERING LIST not change it (different font & size).
i want the VBA code work with step like this:
1. first time, when running vba, automatic select all document/paragraph then simultan automatically change font & size to be ARIAL font with Size 11 (include numbering list)
2. the vba code can work/save as MS Word Add-Ins.
here attachment picture more detail information
susanto
I am looking for VBA code in MS Word to make numbered list (bullet & numbering) in a Word document same font & same font size
often, when select all document then change font & size for NUMBERING LIST not change it (different font & size).
i want the VBA code work with step like this:
1. first time, when running vba, automatic select all document/paragraph then simultan automatically change font & size to be ARIAL font with Size 11 (include numbering list)
2. the vba code can work/save as MS Word Add-Ins.
here attachment picture more detail information
susanto
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
Does this do what you want?
Code: Select all
Sub ChangeFont()
With ActiveDocument.Content.Font
.Name = "Arial"
.Size = 11
End With
End Sub
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 240
- Joined: 17 Feb 2022, 05:16
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
hi Hans, thank but fully work.
if document contains bullet & numbered (numbered list) the font can't change (name font & size font not change)..
if document contains bullet & numbered (numbered list) the font can't change (name font & size font not change)..
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
Sorry, I don't understand that. Do you mean that the code does not change the numbering font (it does when I run the macro) or that it should leave the numbering font unchanged?
(I won't reply soon - it's after midnight here)
(I won't reply soon - it's after midnight here)
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 240
- Joined: 17 Feb 2022, 05:16
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
ok, Hans, Good Night.
when i run the macro, all document change font & size, only list font of number e.g.1,2,3,4,etc...unchanged.
no matter you should take a rest.
when i run the macro, all document change font & size, only list font of number e.g.1,2,3,4,etc...unchanged.
no matter you should take a rest.
-
- 3StarLounger
- Posts: 240
- Joined: 17 Feb 2022, 05:16
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
here new attachment
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
Try this:
Code: Select all
Sub ChangeFont()
Dim par As Paragraph
With ActiveDocument.Content.Font
.Name = "Arial"
.Size = 11
End With
For Each par In ActiveDocument.ListParagraphs
With par.Range.ListFormat.ListTemplate.ListLevels(1).Font
.Name = "Arial"
.Size = 11
End With
Next par
End Sub
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 240
- Joined: 17 Feb 2022, 05:16
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
hi Hans, thank you. Working perfect!!!
-
- 5StarLounger
- Posts: 626
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
Much better, though, in my opinion, is to utilize styles. Attach your numbering to existing paragraph styles, perhaps base those styles on a basic Body Text style, and simply change the font used in the Body Text style. Everything else falls in line. See how styles in Microsoft Word Cascade by Word MVP Shauna Kelly. http://shaunakelly.com/word/styles/hows ... scade.html
If you are doing much of your formatting as Direct Formatting rather than through styles, you are shooting yourself in the foot. You are making more work and more frustration for yourself. This is true with vba as well as manually. http://www.addbalance.com/usersguide/st ... m#Overview
If you are doing much of your formatting as Direct Formatting rather than through styles, you are shooting yourself in the foot. You are making more work and more frustration for yourself. This is true with vba as well as manually. http://www.addbalance.com/usersguide/st ... m#Overview
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- NewLounger
- Posts: 9
- Joined: 26 Feb 2024, 21:56
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
Dear Hans,HansV wrote: ↑25 Feb 2022, 08:32Try this:
Code: Select all
Sub ChangeFont() Dim par As Paragraph With ActiveDocument.Content.Font .Name = "Arial" .Size = 11 End With For Each par In ActiveDocument.ListParagraphs With par.Range.ListFormat.ListTemplate.ListLevels(1).Font .Name = "Arial" .Size = 11 End With Next par End Sub
I want to change the font and size for all list levels, but not just level 1, what I do, please?
Thanks
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
Welcome to Eileen's Lounge!
Do you want to set the same font name and size for all levels, or do you want to set them for each level individually?
Do you want to set the same font name and size for all levels, or do you want to set them for each level individually?
Best wishes,
Hans
Hans
-
- NewLounger
- Posts: 9
- Joined: 26 Feb 2024, 21:56
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
Thanks so much
Thanks for your helpful forum
Yes, the same font and size for all levels
if I want to set each level individually, I think I will use this line to do that
Code: Select all
With par.Range.ListFormat.ListTemplate.ListLevels(n).Font
n= certain level
Thanks again
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
See if this does what you want.
Code: Select all
Sub ChangeFont()
Dim par As Paragraph
Dim n As Long
With ActiveDocument.Content.Font
.Name = "Arial"
.Size = 11
End With
For Each par In ActiveDocument.ListParagraphs
With par.Range.ListFormat
n = .ListLevelNumber
With .ListTemplate.ListLevels(n).Font
.Name = "Arial"
.Size = 11
End With
End With
Next par
End Sub
Best wishes,
Hans
Hans
-
- NewLounger
- Posts: 9
- Joined: 26 Feb 2024, 21:56
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
Thanks so muchHansV wrote: ↑27 Feb 2024, 15:42See if this does what you want.
Code: Select all
Sub ChangeFont() Dim par As Paragraph Dim n As Long With ActiveDocument.Content.Font .Name = "Arial" .Size = 11 End With For Each par In ActiveDocument.ListParagraphs With par.Range.ListFormat n = .ListLevelNumber With .ListTemplate.ListLevels(n).Font .Name = "Arial" .Size = 11 End With End With Next par End Sub
It works perfectly
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 4StarLounger
- Posts: 586
- Joined: 14 Nov 2012, 16:06
Re: VBA:Make Font, Size, Numbered List Same Format (Arial 11)
Use Word's builtin options:
Code: Select all
Sub M_snb()
With ActiveDocument.ListTemplates(1)
.Name = "snb"
.ListLevels(1).Font.Name = "Arial"
.ListLevels(1).Font.Size = 11
End With
End Sub