Solved

Converting placeholder bookmark to enclosing bookmark

Posted on 2004-04-12
4
553 Views
Last Modified: 2006-11-17
Hi All,
I want to paste text next to a placeholder bookmark and make the bookmark enclose the text..

I am using the following code ...

objDocTemp.Bookmarks(objBookMark.Name).Range.Copy
bkName = objBookMark.Name
Set bkRange = objDocNew.Bookmarks(objBookMark.Name).Range
bkRange.PasteSpecial
bkRange.Collapse direction:=wdCollapseStart
objDocNew.Bookmarks.Add Name:=bkName, Range:=bkRange

But this code copies the text and inserts the bookmark after it.


Can anybody help me out.........

Thanks
Ramya

0
Comment
Question by:ramyaj
4 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 20 total points
Comment Utility
Try this

Application.Selection.GoTo What:=wdGoToBookmark, Name:=objBookMark.Name
bkName = objBookMark.Name
Set bkRange = objDocNew.Bookmarks(objBookMark.Name).Range
pos = bkRange.End - bkRange.Start
bkRange.PasteSpecial
bkRange.Collapse direction:=wdCollapseStart
Application.Selection.MoveRight Unit:=wdCharacter, Count:=pos, Extend:=wdExtend
objDocNew.Bookmarks.Add Name:=bkName, Range:=bkRange

where application is your word.application
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

10 Experts available now in Live!

Get 1:1 Help Now