Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a bulleted list in word

Status
Not open for further replies.

MajP

Technical User
Aug 27, 2005
9,382
US
I am reading two recordsets from Access and pushing the text into a Word document. I can write the records no problem and can indent as necessary. So my output looks like

ParentRecord 1
Child record
child Record
child Record
ParentRecord 2
child record
child record
ParentRecord 3

Where each record ends with a carriage return. If I apply
.listformat.applybulletdefault
to the entire range then I get a bulleted list, but everything reverts to the same level. I am not very familiar with the listformat object so any suggestions would be appreciated to construct a bulleted list with different bullet symbols per level.
 
Major,

Can you format your output to preceed the level 2 text with a TAB character indent?

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


Before you try the former, try this...

Using Find > Replace...

replace manual line break with paragraph mark
[tt]
FIND: ^l
REPL: ^p
[/tt]
replace nonbreaking space (2 of them) with tab
[tt]
FIND: ^s^s
REPL: ^t
[/tt]


Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks Skip. Actually I am forcing the tab and the hard returns into the level two text. But when I selected the entire range it converted everything into level one bullets. Here is what I tried:

Code:
Public Sub InsertTasks(wrdDoc As Word.Document, rng As Word.Range, Program_ID As String)
   Dim rsTasks As DAO.Recordset
   Dim strText As String
   Dim strSql As String
   Dim tempStart As Long
   Dim rngLst As Word.Range
   strSql = "SELECT * from qryWordTasks WHERE Program_ID = '" & Program_ID & "'"
   Set rsTasks = CurrentDb.OpenRecordset(strSql, dbOpenDynaset)
   Set rng = wrdDoc.Range(rng.End, rng.End)
   tempStart = rng.End
   Do While Not rsTasks.EOF
     
strText = Trim(rsTasks.Fields("Subject")) & " - " + Trim(rsTasks.Fields("Notes")) & vbCrLf

     rng.Text = strText
     rng.ListFormat.ApplyBulletDefault
     rng.Font.Name = "Times New Roman"
     rng.Font.Size = 12
     Set rng = wrdDoc.Range(rng.End, rng.End)

     Call InsertActions(wrdDoc, rng, rsTasks.Fields("Task_ID"))
     rsTasks.MoveNext
   Loop

'here is the formatting code  It selects all level two and
'level one strings
 
   Set rngLst = wrdDoc.Range(tempStart, rng.End)
   rngLst.ListFormat.ApplyBulletDefault

End Sub

Public Sub InsertActions(wrdDoc As Word.Document, rng As Word.Range, TaskID As Long)
   Dim rsActions As DAO.Recordset
   Dim strText As String
   Dim strSql As String
   strSql = "SELECT * from qryWordActions WHERE Parent_ID = " & TaskID
   Set rsActions = CurrentDb.OpenRecordset(strSql, dbOpenDynaset)
   Set rng = wrdDoc.Range(rng.End, rng.End)
   Do While Not rsActions.EOF

     strText = vbTab & Trim(rsActions.Fields("Subject")) & " - " + Trim(rsActions.Fields("Notes")) & vbCrLf

     rng.Text = strText
     rng.Font.Name = "Times New Roman"
     rng.Font.Size = 12
     Set rng = wrdDoc.Range(rng.End, rng.End)

     rsActions.MoveNext
   Loop
End Sub

The level one strings are my "Tasks", the level 2 strings are my "Actions" related to a "Task"

I can make it work manually by selecting the range and converting it to a bulleted list. Then the indented levels become level 2 bullets. I thought that this would be equivalent to that action

Set rngLst = wrdDoc.Range(tempStart, rng.End)
rngLst.ListFormat.ApplyBulletDefault

However, that just changes everything to level one bullets.
 
Maybe another way to ask the question without all of the background. If I have this range of text:

String level one
string level two
string level two
string level two
String level one
string level two
string level two
String level one

with all strings ending with a hard return (vbcrlf) and all levels two string starting with a tab (vbtab). What code do I use on the range to convert to bulleted list?
 
Turn on your macro recorder and format the multi-level bullets you want.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top