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
328 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Transferring select excel data to a Word Document 5 53
Word 2010 mail merge 3 61
Select tabs in Word with Powershell 8 43
Regarding Notepad++ 4 34
There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

914 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

17 Experts available now in Live!

Get 1:1 Help Now