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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Word Writer 1 59
stop word moving down 2 63
Words Divided at end of line - how to correct whose document (Word 2013) 9 76
Mail merge IF Statements 8 48
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
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…

809 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