Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Converting placeholder bookmark to enclosing bookmark

Posted on 2004-04-12
4
Medium Priority
?
591 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
[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
4 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 80 total points
ID: 10804911
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

721 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