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
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel copy picture into Outlook email 7 70
delete blank pages by means of VBA 10 37
How to insert clean border ? 6 39
Unable to open powerpoint presentation 6 46
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…
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…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.

738 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