Solved

How do I select a particular word that has a bookmark in the middle of it withMS Word VBA

Posted on 2013-01-28
2
330 Views
Last Modified: 2013-01-28
I have placed numerous bookmarks in the middle of words in my document is there anyway to select those words and change their formatting using MS WORD VBA
0
Comment
Question by:Dov_B
2 Comments
 
LVL 1

Accepted Solution

by:
juicecap earned 500 total points
ID: 38829321
Try working with this...

With ActiveDocument .Bookmarks("bkName")
    .Range.InsertBefore txtName.Value
    .Range.Font.Bold = True
End With
See the article "Working with Bookmarks in VBA” at:
http://www.word.mvps.org/FAQs/MacrosVBA/WorkWithBookmarks.htm
If the bookmarks already exist as "PlaceHolder" Bookmarks, you could use the following code:
Dim bmRange As Range
Set bmRange = ActiveDocument.Bookmarks("bkName").Range
With bmRange
   .Text = txtName.Value
   .Font.Bold = True
End With
0
 

Author Closing Comment

by:Dov_B
ID: 38829324
Dim k As Bookmark
For Each k In ActiveDocument.BookMarks
k.Select
Selection.Expand Unit:=wdWord
HighliteYellow
Next
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question