bullet lists

N

Nathan Franklin

Hello,

could someone please point me in the right direction of how to create bullet
lists with vba??

Thanks
Nathan
 
J

Jezebel

Easiest method is to define a style (eg "Bullet"), then use myRange.Style =
"Bullet". It's possible to set up the bulleting itself via VBA (read help on
ListGalleries) but a) it's a lot of work, and b) it means your formatting is
hard-coded.
 
N

Nathan Franklin

Jezebel, thanks for your reply,

just had another question,
i try and insert each point like so
Dim CurrentSummaryIndex As Int16 = 1

Dim SummaryRange As Word.Range =
Doc.Bookmarks.Item("SignificantMattersSummaryPoints").Range

SummaryRange.Style = "List Bullet"

For Each rSummary In dSummary.Rows

SummaryRange.InsertBefore(dbNull(rSummary("SummaryPoint")))

If Not dSummary.Rows.Count = CurrentSummaryIndex Then

SummaryRange.InsertParagraphAfter()

SummaryRange.Collapse(Word.WdCollapseDirection.wdCollapseEnd)

'Exit For

End If

CurrentSummaryIndex += 1

Next



my problem is that when i try to appy an individual style to these items
(italics or bold) all of them chnge there style. Is there anyway around
this??
 
J

Jezebel

Is the style set to update automatically?


Nathan Franklin said:
Jezebel, thanks for your reply,

just had another question,
i try and insert each point like so
Dim CurrentSummaryIndex As Int16 = 1

Dim SummaryRange As Word.Range =
Doc.Bookmarks.Item("SignificantMattersSummaryPoints").Range

SummaryRange.Style = "List Bullet"

For Each rSummary In dSummary.Rows

SummaryRange.InsertBefore(dbNull(rSummary("SummaryPoint")))

If Not dSummary.Rows.Count = CurrentSummaryIndex Then

SummaryRange.InsertParagraphAfter()

SummaryRange.Collapse(Word.WdCollapseDirection.wdCollapseEnd)

'Exit For

End If

CurrentSummaryIndex += 1

Next



my problem is that when i try to appy an individual style to these items
(italics or bold) all of them chnge there style. Is there anyway around
this??
 
N

Nathan Franklin

i think it might have been because the bookmark range was assigned on
particular style..??

i have fixed it though... after spending over 3 hours on it... I ended up
recording the macro from word and using the selection object

Some have said using the selection object is bulky and slow... I have run
tests on how long it takes to run the code and it ends up being less then
200ms. So im stoked...

for reference this is what i did...

Doc.Bookmarks.Item("SignificantMattersSummaryPoints").Select()

App.Selection.Style = "Normal"

App.Selection.Range.ListFormat.ApplyListTemplate(ListTemplate:=App.ListGalleries.Item(
_

Word.WdListGalleryType.wdBulletGallery).ListTemplates.Item(1),
ContinuePreviousList:=False, ApplyTo:= _

Word.WdListApplyTo.wdListApplyToWholeList)

For Each rSummary In dSummary.Rows

App.Selection.TypeText(dbNull(rSummary("SummaryPoint")))

If Not CurrentSummaryIndex = dSummary.Rows.Count Then

App.Selection.TypeParagraph()

CurrentSummaryIndex += 1

End If

Next
 
J

Jezebel

Better and simpler would be ---

with Doc.Bookmarks.Item("SignificantMattersSummaryPoints")
.Style = "Normal"
.ListFormat.ApplyListTemplate(ListTemplate:=App.ListGalleries.Item(
....
end with
 
N

Nathan Franklin

hey jezebel...
this method didnt work...

the correct output is this...
· summary point 1

· summary point 2

· summary point 3

· summary point 4

· summary point 5

this is what i get with the code you gave me...
·

· summary point 5





i would likew to use ranges if i could, because they are faster right??



here is the middle part of the code..

For Each rSummary In dSummary.Rows

.InsertAfter(dbNull(rSummary("SummaryPoint")))

If Not CurrentSummaryIndex = dSummary.Rows.Count Then

.InsertParagraph()

CurrentSummaryIndex += 1

End If

Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top