Reaching a bookmark inside a textbox ?


R

rozwel

I've got a Word document with a textbox inside. Each line in the textbox has
a bookmark and I have also defined a bookmark outside the textbox, in the
main document.

I'm working on a VBA Sub which has to fill in the lines of the textbox and
then go back to the beginning of the document.

My problem is that I can reach the bookmark in the main document thanks to
the Selection.GoTo Function, but the bookmarks inside the textbox are not
visible through the same mechanism.

Do I have to use another method instead, using fields or another method
instead or before GoTo in order to select the textbox first ?

Thanks in advance.

rozwel
 
Ad

Advertisements

C

Cindy M -WordMVP-

Hi Rozwel,

Don't select or goto any bookmarks where you are only passing in text. Work
directly with the object model, instead:

doc.Bookmarks("Name").Range.Text = "The text"
I've got a Word document with a textbox inside. Each line in the textbox has
a bookmark and I have also defined a bookmark outside the textbox, in the
main document.

I'm working on a VBA Sub which has to fill in the lines of the textbox and
then go back to the beginning of the document.

My problem is that I can reach the bookmark in the main document thanks to
the Selection.GoTo Function, but the bookmarks inside the textbox are not
visible through the same mechanism.

Do I have to use another method instead, using fields or another method
instead or before GoTo in order to select the textbox first ?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
Ad

Advertisements

Joined
Jan 16, 2022
Messages
1
Reaction score
0
Hi Rozwel,

Don't select or goto any bookmarks where you are only passing in text. Work
directly with the object model, instead:

doc.Bookmarks("Name").Range.Text = "The text"


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
Thanks a lot! It worked for me!!
doc being:
Dim Obj_Word As Object
Set Obj_Word = CreateObject("Word.Application")
Set doc = Obj_Word.ActiveDocument
 

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