Changing Start position of a Selection

K

ksr

Hi all,

I have the following question.
I have text hyperlinks, bookmarks and pictures in my word document.

For a text hyperlink,

selObj = Field.Selection()
selObj.GetText()

returns the text of the selection. (for ex. "www.google.com")
If I do the following,

pos1 = selObj.GetStart()
pos2 = selObj.GetEnd()

selObj.SetStart(pos1+ 4)
selObj.SetEnd(pos2+ 4)
selObj.GetText()

It still returns the same text for me.
My question is, will it change the selection? Will it return the text
"google.com "?
Pls. let me know.

Thankyou.
 
C

Cindy M -WordMVP-

Hi Ksr,

Working with the Selection object and a field is a tricky proposition
because some versions of Word can be set to NOT select the entire field
when an end of the field is selected. IOW, you can't really be sure
what your selection contains.

I'd say, for this task you'd be better off manipulating the text
string. Very roughly:

Dim sHyperlinkText as String

sHyperlinkText = selObj.GetText()
MsgBox Mid(sHyperlinkText, 4)
I have the following question.
I have text hyperlinks, bookmarks and pictures in my word document.

For a text hyperlink,

selObj = Field.Selection()
selObj.GetText()

returns the text of the selection. (for ex. "www.google.com")
If I do the following,

pos1 = selObj.GetStart()
pos2 = selObj.GetEnd()

selObj.SetStart(pos1+ 4)
selObj.SetEnd(pos2+ 4)
selObj.GetText()

It still returns the same text for me.
My question is, will it change the selection? Will it return the text
"google.com "?
Pls. let me know.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
J

jay

This opens up a whole new world for me. How do I go about learning the code
used by macros?
 
C

Cindy M -WordMVP-

Hi Jay,
This opens up a whole new world for me. How do I go about learning the code
used by macros?
I'm not sure I understand your question, because I don't know your background.
Have you tried a book like Word 97 Macro and VBA Handbook or perhaps Word 2000
VBA Programmer's Reference?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 

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