PDA

View Full Version : Solved: How to Format Contents of Multiline Textbox in a Userform into Bullets



em.
07-13-2008, 10:50 PM
Hi there,

I have been searching around quite a bit and not found an answer that works for me. Hopefully I can get further in this forum. Thanks for any help :)

I've created a userform in Word and added the following code in an attempt to format the contents of a multiline textbox into a bulleted list when the user clicks on the OK command button:


With ActiveDocument.Bookmarks("FaxPoints").Range
.Text = strFaxPoints
.ListFormat.ApplyBulletDefault
End With


This code only seems to apply the bullets to the first line of textbox contents. Can anyone please advise if there is a way to get all the paragraphs in the textbox to format as bullets regardless of how many paragraphs are used? The user hits Enter to get to the next line of the textbox.

Thanks heaps em. :)

Nelviticus
07-14-2008, 01:06 AM
Just execute the two lines in reverse order - apply the ListFormat first, then set the text.

em.
07-14-2008, 01:57 AM
Hi Nelviticus, Just did a quick test, with the following code and it didn't work, have I got the code the right way around?


With ActiveDocument.Bookmarks("FaxPoints").Range
.ListFormat.ApplyBulletDefault
.Text = strFaxPoints
End With


Only the first line of the text box shows a bullet in the document.

Thanks :) em.

Nelviticus
07-14-2008, 02:07 AM
Hmm, well it worked for me :(

Actually, I've just tested it and the original way works too. In fact try as I might I can't get it to not work. Sorry about that, I appear to have muddied the issue!

Is the text in the textbox in any way unusual?

lucas
07-14-2008, 11:04 AM
Suggestion: Maybe create a bulleted style and apply that to the range?

em.
07-14-2008, 04:15 PM
Thanks for all your help :) It got me thinking as to why yours worked Nelviticus, and mine wouldn't - it was the same code after all.

After a bit of a play, I now have it working - I moved that particular piece of code to the start of the code: Private Sub cmdOK_Click() I had it at the bottom before.

On a side note, lucas could you please give me a sample code to indicate how I would apply a custom bullet style to my range?

Many thanks ;)

lucas
07-15-2008, 11:25 AM
Try this for applying a style em. You have to create on in the document first.....I named it bullets.

Sub a()
Dim strFaxPoints As String
strFaxPoints = "Now is the time for all good men to come to the aid of thier country."
With ActiveDocument.Bookmarks("FaxPoints").Range
.Style = "bullets"
.Text = strFaxPoints
End With
End Sub

em.
07-17-2008, 11:31 PM
Hey, thanks for that. Really great stuff! It's given me a great starting point.

Thanks everyone :)