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
325 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
Comment Utility
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
Comment Utility
Dim k As Bookmark
For Each k In ActiveDocument.BookMarks
k.Select
Selection.Expand Unit:=wdWord
HighliteYellow
Next
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now