how to set the cursor(mouse pointer) at the end of the bookmark?

P

praveen

Hi,

I am adding a bookmark dynamically in word document using vb.net. All i
want is i want to set my cursor position(mouse pointer) at the end of the
bookmark text.

Here is the code i am using to create bookmark.

Dim rng As Object

rng.Text = "bookmark1 text"

Connect.applicationObject.activedocument.Bookmarks.Add("bookmark1", rng)



Any help would be appreciated

cheers

Praveen
 
D

Dave Lett

Hi,


Dim rng As Range
Set rng = Selection.Range
rng.Text = "bookmark1 text"
ActiveDocument.Bookmarks.Add "bookmark1", rng
rng.Collapse Direction:=wdCollapseEnd
rng.Select

HTH,
Dave
 
P

praveen

Hi Dave,

Thanks for your reply and it did work fine. Is there any way to add extra
space at the end of the bookmark text and set the cursor over there.

for exmaple [bookmarktext] I

where I is the cursor point or mouse pointer.

Cheers

Praveen
 
G

Greg Maxey

Sub Test()
Dim rng As Range
Set rng = Selection.Range
rng.Text = "bookmark1 text"
ActiveDocument.Bookmarks.Add "bookmark1", rng
rng.InsertAfter " "
rng.Collapse Direction:=wdCollapseEnd
rng.Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top