Log in

View Full Version : Add Bullets to Word Document (from Access)



Adaytay
01-06-2006, 02:31 AM
Hey all, happy new year!

I'm currently in the middle of coding up a Word Document that gets controlled from word. This word doc is actually an invoice Cover Letter (the invoice is generated seperately).

Part of the word document contains a list of documents that accompany the invoice, this is collated from within Access and copied across into the word document at a specific bookmark.

Access then uses the following code (note this is not the entire procedure) to select the list and then convert it to a bulleted list. Trouble is, the code worked the first time I ran it but it won't work again?? Oh, I should add that this code is what the Word Macro recorded, modified to run from Access.


'Add in the types of documentation that we have now...
.Bookmarks("IncludedDocs").Select
objWord.Selection.TypeText strDocuments 'strDocuments gets set in BuildCostsTable so we can use this!


'That's the text in, now select the inserted text, and convert to bullet points
.Bookmarks("IncludedDocs").Select
objWord.Selection.MoveDown Unit:=wdLine, Count:=intCount, Extend:=wdExtend
With objWord.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
.Color = wdColorRed
.Name = "Symbol"
End With
.LinkedStyle = ""
End With
objWord.ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
objWord.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
wdBulletGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:= _
wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior


Any ideas?

Thanks,

Ad

fumei
01-06-2006, 08:32 AM
1. PLEASE use the underscore character when posting. Not all of us have large monitors and function with high-rez. It makes it very difficult to read code.

Actually, in this case if you just edit your post and put the comment:
'strDocuments gets set in BuildCostsTable
on a separate line it won't stretch out so far.

The reason it works the first time, but NOT after is that the bookmark is NOT resized to actually include the inserted text. Yes you extend the selection, so it works the first time. I assume that what is happening is that the next iteration is inserted BEFORE the previous text?

If this is the case, please state that it is. It helps to state what IS happening. "it won't work" does not tell us anything really.

If it IS what is happening - there is a a fairly easy solution.

BTW: I am a bit confused.

coding up a Word Document that gets controlled from word
It does not look like it is "controlled from word". Especially when you state:

Access then uses the following code
sounds like Access is doing the controlling.

Minor point.

Anyway, please state if what is happening is that you have new insertions being placed prior to the previous inserted text. Either that or state clearly what is NOT working.