I'm having some problems converting VBA for Word 2000 to code that
VB.Net understands. I recorded a macro in Word to add numbering (a.
b. c.) to my paragraphs. I managed to translate quite a bit of it,
but I'm having trouble with two pieces:
ListGalleries - I can't find any way to make VB.Net understand this.
When I do a mouseover, the error message it gives is, "Interface
'Word.ListGalleries' cannot be indexed because it has no default
property."
PointToInches - Not sure VB.Net even has a way to translate it.
Here is the Macro I recorded, followed by my transalted VB.Net code. I
removed some of the code I thought would be unnecessary to the
translation, but I could be wrong.
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 9/14/2004 by H2O
'
With ListGalleries(wdNumberGallery).ListTemplates(6).Li stLevels(1)
.NumberFormat = "%1."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleLowercaseLetter
.NumberPosition = InchesToPoints(0.25)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.5)
.TabPosition = InchesToPoints(0.5)
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Bold = wdUndefined
.Italic = wdUndefined
.StrikeThrough = wdUndefined
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdUndefined
.Size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = ""
End With
.LinkedStyle = ""
End With
ListGalleries(wdNumberGallery).ListTemplates(6).Na me = ""
Selection.Range.ListFormat.ApplyListTemplate
ListTemplate:=ListGalleries( _
wdNumberGallery).ListTemplates(6),
ContinuePreviousList:=False, ApplyTo:= _
wdListApplyToWholeList,
DefaultListBehavior:=wdWord9ListBehavior
Selection.TypeText Text:="Blah blah blah"
Selection.TypeParagraph
Selection.TypeText Text:="Gah gah gah"
Selection.TypeParagraph
Selection.TypeText Text:="Wee wee wee"
End Sub
------- Begin VB.Net Code -------
Private Sub testing(ByVal owordnew As Word.Application)
With owordnew
With .ListGalleries(Word.WdListGalleryType.wdNumberGall ery).ListTemplates(6).ListLevels(1)
.NumberFormat = "%1."
.TrailingCharacter =
Word.WdTrailingCharacter.wdTrailingTab
.NumberStyle =
Word.WdListNumberStyle.wdListNumberStyleLowercaseL etter
.NumberPosition = InchesToPoints(0.25)
.Alignment =
Word.WdListLevelAlignment.wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.5)
.TabPosition = InchesToPoints(0.5)
.ResetOnHigher = 0
.StartAt = 1
.LinkedStyle = ""
End With
.ListGalleries(Word.WdListGalleryType.wdNumberGall ery).ListTemplates(6).Name
= ""
.Selection.Range.ListFormat.ApplyListTemplate(List Template:=ListGalleries(
_
Word.WdListGalleryType.wdNumberGallery).ListTempla tes(6),
ContinuePreviousList:=False, ApplyTo:= _
Word.WdListApplyTo.wdListApplyToWholeList,
DefaultListBehavior:=Word.WdDefaultListBehavior.wd Word9ListBehavior)
.Selection.TypeText(Text:="Blah blah blah")
.Selection.TypeParagraph()
.Selection.TypeText(Text:="Gah gah gah")
.Selection.TypeParagraph()
.Selection.TypeText(Text:="Wee wee wee")
End With
End Sub
Thanks for any assistance,
MW