Terry_Orange
Board Regular
- Joined
- Jul 22, 2002
- Messages
- 133
Hi folks,
I have code to write information from Excel to Word, text, images, graphs, tables etc but given I have some information
eg.
FRUITS
apples
pears
bananas
I would like to write a list in the Word document that I create on the fly.
I have tried using the Word macro recorder and pasting this within Excel:
where obj is my word document that I have created / opened....
It returns an error saying that Method 'ApplyListTemplate' of object 'ListFormat' failed
Anyone any ideas ? Anyone tried creating a LIST in word automatically from Excel ????
Thanks again for the help...
TO.
I have code to write information from Excel to Word, text, images, graphs, tables etc but given I have some information
eg.
FRUITS
apples
pears
bananas
I would like to write a list in the Word document that I create on the fly.
I have tried using the Word macro recorder and pasting this within Excel:
Code:
With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = ChrW(61623)
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleBullet
.NumberPosition = CentimetersToPoints(0.63)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(1.27)
.TabPosition = CentimetersToPoints(1.27)
.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 = "Symbol"
End With
.LinkedStyle = ""
End With
ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
obj.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
wdBulletGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:= _
wdListApplyToWholeList, DefaultListBehavior:=wdWord9ListBehavior
obj.Selection.TypeText Text:="apples"
obj.Selection.TypeParagraph
obj.Selection.TypeText Text:="bananas"
obj.Selection.TypeParagraph
obj.Selection.TypeText Text:="pears"
obj.Selection.TypeParagraph
where obj is my word document that I have created / opened....
It returns an error saying that Method 'ApplyListTemplate' of object 'ListFormat' failed
Anyone any ideas ? Anyone tried creating a LIST in word automatically from Excel ????
Thanks again for the help...
TO.