Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Create a bullet list automatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Neale - 16 Feb 2006 16:09 GMT
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 :o(

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
Neale - 16 Feb 2006 16:20 GMT
A bit more information - sorry;

I am running the code from within an access 2003 database.
I am using word 2000
Shauna Kelly - 19 Feb 2006 06:24 GMT
Hi Neale

Try something like this:

set wdRange  = *whatever*
wdRange.Style = wdStyleListBullet

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

>A bit more information - sorry;
>
> I am running the code from within an access 2003 database.
> I am using word 2000
Neale - 22 Feb 2006 09:39 GMT
Thanks Shauna,

This works just fine, but only providing the style is applied to an existing
block of text in a range, whereas some of the other methods I was reviewing
apply the style to a range object and then add the text to the styled range,
which requires that the style be turned off as well.

If I apply a style using this method to an empty range and then add text to
the range, it does not apply the style, however my original plan was to build
the list and then apply the style so it's perfect for me, thanks again.

> Hi Neale
>
[quoted text clipped - 12 lines]
> > I am running the code from within an access 2003 database.
> > I am using word 2000
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.