Report formatting - Bulleted lists

D

DD

I have four documents which make up the sections of a report we issue to a
client. I want to use VBA macros to control the formatting and make the
reports consistent.

I have created a macro which sets the bullet formatting for the selected
bullets (see below) and I have had some help from Jean-Guy Marcil, Helmut
Weber, and Doug Robbins, to come up with a maco that formats all the tables
in the document.

How would I edit my bullet formatting macro so that it is applied to all
bullet lists in the open document?

Sub fmtBulletAlignment()
'
' Clear all tab stops
' Add new tab stops for next/additional column
' Setup Bullet and text locations

Selection.ParagraphFormat.TabStops.ClearAll
Selection.ParagraphFormat.TabStops.Add
Position:=CentimetersToPoints(11.2 _
), Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
Selection.ParagraphFormat.TabStops.Add
Position:=CentimetersToPoints(2.2), _
Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces

With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(2.2)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 3
.SpaceBeforeAuto = False
.SpaceAfter = 3
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(-0.75)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
End Sub

Regards
D Dawson
 
H

Helmut Weber

Hi D,

what is D?

like this:

Sub Macro12()
Dim rLprg As Range ' a listparagraph's range
For Each rLprg In ActiveDocument.ListParagraphs
With rLprg.ParagraphFormat
' pseudocode
' .property:=wdconstant or value
End With
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
D

DD

Helmut

Are you sure that this will only change the bullets? My report contains
paragraph numbers which I don't need changed.

Also, the macro doesn't work, in debug mode the line...
For Each rLprg In ActiveDocument.ListParagraphs
changes to yellow and I get rLprg = 0

The formatting part is simple enough, I just record what I want it to do,
using a selection. I want to learn how to change a selection macro into a
macro that will select the items for itself. I want to change the macro so
that it goes through the document and changes each bulleted list using the
formatting I have recorded.

This is what I have:

Sub FmtBullets()

Dim rLprg As Range ' a listparagraph's range
For Each rLprg In ActiveDocument.ListParagraphs
With rLprg.ParagraphFormat

.LeftIndent = CentimetersToPoints(2.2)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 3
.SpaceBeforeAuto = False
.SpaceAfter = 3
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(-0.75)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
Next
End Sub


Regards
Dylan Dawson
Building Surveyor
Glasgow, Scotland
 
H

Helmut Weber

Hi Dylan,

programming is very much a process of trial and error,
at least for me.

How about this one:

Sub Macro12A()
Dim rLprg As Paragraph
For Each rLprg In ActiveDocument.ListParagraphs
rLprg.Range.Select ' for testing
'rLprg.Range.ParagraphFormat....
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
D

DD

Helmut,

Thanks, I used your advice and your test macro to test the selections.
I also had to dig about a bit further and eventually came up with the
following, which seems to do what I need:
It was actually the ListFormat.ListType property that I was looking for.

Sub FmtBulletList()
Dim rLprg As Paragraph
Dim yPara As Range

For Each rLprg In ActiveDocument.ListParagraphs

If rLprg.Range.ListFormat.ListType = WdListType.wdListBullet Then
Set yPara = rLprg.Range
'rLprg.Range.Select ' for testing

'Clear all tabs and setup new tabs
With rLprg.Range.ParagraphFormat
.TabStops.ClearAll
.TabStops.Add Position:=CentimetersToPoints(11.2 _
), Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
.TabStops.Add Position:=CentimetersToPoints(2.2), _
Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
End With

'Setup formatting
With rLprg.Range.ParagraphFormat
.LeftIndent = CentimetersToPoints(2.2)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 3
' and so on with the formatting
End With

End If
Next
End Sub

Regards
Dylan Dawson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

set hanging indent for second TOC 1
TOC Help 0
TOC Problem 0
TOC Question 3
Table of Content 1
Converting Visual Basic inside Word Document to VBScript 2
TOC problem 0
A macro to increase line spacing 1

Top