Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSWord numbered lists

Status
Not open for further replies.

Al2142

Programmer
Joined
May 16, 2008
Messages
1
Location
US
Hi,

I have a script I converted from VBA (the script does work in VBA) to VBScript. It uses the Word object. I am trying to apply new formatting to existing numbered lists in a document. There may be more than one. Everything appears to work except the actual application of the style.

Here's the existing code:

For Each strList in objWord.ActiveDocument.ListParagraphs

With objWord.ListGalleries(2).ListTemplates(1).ListLevels(1)
.NumberFormat = "%1."
' .TrailingCharacter = wdTrailingTab
.TrailingCharacter = 2
' .NumberStyle = wdListNumberStyleArabic
.NumberStyle = 0
' .NumberPosition = InchesToPoints(0.25)
.NumberPosition = objWord.InchesToPoints(0)
' .Alignment = wdListLevelAlignLeft
.Alignment = 0
' .TabPosition = InchesToPoints(0.5)
.TabPosition = objWord.InchesToPoints(0.25)
' .TextPosition = InchesToPoints(0.5)
.TextPosition = objWord.InchesToPoints(0.25)
.ResetOnHigher = 0
.StartAt = 1
.LinkedStyle = ""
End With

objWord.ListGalleries(2).ListTemplates(1).Name = ""
objWord.Selection.Range.ListFormat.ApplyListTemplate objWord.ListGalleries(2).ListTemplates(1), 0, 0, 2


Here is the original VBA code for reference.

With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = "%1."
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.5)
.TabPosition = InchesToPoints(0.5)
.ResetOnHigher = 0
.StartAt = 1
.LinkedStyle = ""
End With
ListGalleries(wdNumberGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
wdNumberGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:= _
wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior


Any thoughts on why the formatting won't apply?

- Al
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top