Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Report formatting - Bulleted lists

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DD - 26 Aug 2006 10:55 GMT
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
Helmut Weber - 26 Aug 2006 12:05 GMT
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

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

DD - 26 Aug 2006 13:50 GMT
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
Helmut Weber - 26 Aug 2006 14:04 GMT
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

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

DD - 26 Aug 2006 16:36 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.