N
Neale
Hi all,
I am trying to output records from a database into a particular part of a
word document. That bit works fine, and I have created a document template
with a bookmark to receive the data.
The problem I have is that the items are not appearing as a bulleted list as
I expect. I have trawled the word object model and tried various methods
without success
(
Here is some of the code I have written (missing the variable declarations),
with the database records being replaced with a for...next loop to create
some lines of data temporarily to test the concept;
Set wdApp = New Word.Application
wdApp.Documents.Open strDocPath & strDocName
Set wdBookmarks = wdApp.ActiveDocument.bookmarks
Set wdLstTemplate = wdApp.ListGalleries(wdBulletGallery).ListTemplates(1)
' Update the document bookmark range with the new text
On Error GoTo Error_DocumentNotValidForExport
Set wdRange = wdApp.ActiveDocument.bookmarks("Requirements").Range
For l% = 1 To sngNumLines
strNewText = strNewText & vbTab & "Auto Line " & l% & " inserted" &
vbCrLf
Next l%
// THIS IS ONE METHOD ATTEMPTED TO APPLY A BULLET FORMAT TO THE LIST
If wdRange.ListFormat.ListType = wdListNoNumbering Then
wdRange.ListFormat.ApplyBulletDefault
End If
// END METHOD
// THIS IS ANOTHER METHOD I TRIED
wdRange.ListFormat.ApplyListTemplate ListTemplate:=wdLstTemplate, _
ContinuePreviousList:=False, ApplyTo:=wdListApplyToWholeList, _
DefaultListBehavior:=wdWord8ListBehavior
// END METHOD
// THE REMAINDER OF THE CODE I AM HAPPY WITH
wdRange.Text = strNewText
wdBookmarks.Add "Requirements", wdRange
On Error GoTo 0
wdApp.ActiveDocument.Save
wdApp.Quit
Set wdBookmarks = Nothing
Set wdLstTemplate = Nothing
Set wdApp = Nothing
I am trying to output records from a database into a particular part of a
word document. That bit works fine, and I have created a document template
with a bookmark to receive the data.
The problem I have is that the items are not appearing as a bulleted list as
I expect. I have trawled the word object model and tried various methods
without success
Here is some of the code I have written (missing the variable declarations),
with the database records being replaced with a for...next loop to create
some lines of data temporarily to test the concept;
Set wdApp = New Word.Application
wdApp.Documents.Open strDocPath & strDocName
Set wdBookmarks = wdApp.ActiveDocument.bookmarks
Set wdLstTemplate = wdApp.ListGalleries(wdBulletGallery).ListTemplates(1)
' Update the document bookmark range with the new text
On Error GoTo Error_DocumentNotValidForExport
Set wdRange = wdApp.ActiveDocument.bookmarks("Requirements").Range
For l% = 1 To sngNumLines
strNewText = strNewText & vbTab & "Auto Line " & l% & " inserted" &
vbCrLf
Next l%
// THIS IS ONE METHOD ATTEMPTED TO APPLY A BULLET FORMAT TO THE LIST
If wdRange.ListFormat.ListType = wdListNoNumbering Then
wdRange.ListFormat.ApplyBulletDefault
End If
// END METHOD
// THIS IS ANOTHER METHOD I TRIED
wdRange.ListFormat.ApplyListTemplate ListTemplate:=wdLstTemplate, _
ContinuePreviousList:=False, ApplyTo:=wdListApplyToWholeList, _
DefaultListBehavior:=wdWord8ListBehavior
// END METHOD
// THE REMAINDER OF THE CODE I AM HAPPY WITH
wdRange.Text = strNewText
wdBookmarks.Add "Requirements", wdRange
On Error GoTo 0
wdApp.ActiveDocument.Save
wdApp.Quit
Set wdBookmarks = Nothing
Set wdLstTemplate = Nothing
Set wdApp = Nothing