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
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