Goto Bookmark--selects the text?

R

Rick

We have an ancient macro written in WordBasic. It has many statements
where it goes to a bookmark:

WordBasic.WW7_EditGoTo Destination:="apple"

One thing I've noticed is that under some circumstances (but not all)
this statement will go to the bookmark and also select the text at that
bookmark. But when I rewrite it in VBA:

Selection.GoTo what:=wdGoToBookmark, Name:="apple"

it doesn't select the text. Any idea what's going on here? Thanks
 
J

Jonathan West

Rick said:
We have an ancient macro written in WordBasic. It has many statements
where it goes to a bookmark:

WordBasic.WW7_EditGoTo Destination:="apple"

One thing I've noticed is that under some circumstances (but not all)
this statement will go to the bookmark and also select the text at that
bookmark. But when I rewrite it in VBA:

Selection.GoTo what:=wdGoToBookmark, Name:="apple"

it doesn't select the text. Any idea what's going on here? Thanks

It all depends whether the bookmark itself selects text. When the bookmark
is inserted, if text is selected, then the bookmark marks the selected text.
However, if you insert the bookmark when the cursor is flashing, that is
also what will happen when you go to the bookmark.
 
R

Rick

Thanks. The bookmarks already exist in the .DOC (it's
not inserted by a macro).

I've delved a bit deeper into this and I see my
description below doesn't get to the heart of the
matter. For many years we've had a Powerbuilder program
that sets up Word as a DDE server. We open the Word
document which already contains bookmarks. Then through
a DDE-related function called SetRemote() Powerbuilder
sends a text string to the Word document at the
specified named bookmark. When we're connected via DDE
like this and using SetRemote(), when the text is sent
to Word the Word bookmark turns from an I-Beam to a pair
of brackets, and the text gets inserted between a left
bracket and a right bracket like this:

[my text gets inserted here]

But we're now re-writing it to use an OLE connection and
to send the text via OLE. Powerbuilder essentially
sends out VBA functions to Word:

PBwordobject.Selection.GoTo what:=wdGoToBookmark, Name:
="apple"

When we do it this way, the Word bookmark remains as an
I-Beam and my text is inserted to its right. There's no
left bracket and no right-bracket.

Any idea what could be going on?
 
R

Rick

Great -- I'll look at that article. The way I'm inserting the text
right now (from Powerbuilder) is with two commands:

wordobj.Selection.Goto(TRUE, 0, 0, "mybookmark")
wordobj.Selection.TypeText("mytext")

Given that, does it make sense that my text would get inserted AFTER the
bookmark, so that the I-beam is BEFORE my text?

With the technique in the article, my text will then appear between left
and right brackets?

Thanks much.
 

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