Formattting Bookmarks

K

Kaykayme

I am trying to format the text passed to a bookmark from a userform. Any
suggestions?
 
J

Jay Freedman

Kaykayme said:
I am trying to format the text passed to a bookmark from a userform.
Any suggestions?

The process is exactly like formatting any other text in a document.
Assuming your macro knows the name of the bookmark, it goes something like
this...

With ActiveDocument.Bookmarks("theBookmarkName").Range
.Font.Name = "Arial"
.Font.Size = 16
.Font.Bold = True
' ...
End With

If you have some other problem, please be more specific about exactly what
you want to do, what your current code contains, and what's happening that
isn't what you want.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
K

Kaykayme

Thanks Jay.
We tried that but if the .Bookmarks("BookmarkName").Range.Text = xx, that is
2 characters instead of 1, only the first character is formatted. What I
have done that works is extend the the bookmark range as follows
Dim bookend
bookend= .Bookmarks("BookmarkName").End + 2
..Bookmarks("BookmarkName").End = bookend

Then I selected the bookmark and formatted the text to red and single
underline. If there is a more efficient way of doing this I would appreciate
any help given.

Thanks!
 
J

Jay Freedman

The problem really isn't at the formatting step, but at the step where you
inserted text at the bookmark. If the text is inserted properly, the
bookmark's range will cover the entire text -- no matter whether it's one
character, two characters, or the whole of War And Peace.

Use the technique shown in
http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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