Hi David,
If you want other than Word's definition of a 'word', you must define your
own. You can extend the selection with something like
Selection.MoveEndUntil "., " & vbCr, wdForward
Selection.MoveStartUntil " " & vbCr, wdBackward
This will look forward for a full stop, comma, space, or carriage return and
backward for a space or carriage return. You will need to also look for
other characters depending on your text - semicolon, question mark, etc.-
and what you want to include in your 'word'.
--
Enjoy,
Tony
> I am trying to write a Word macro that selects the current word and
> then does some processing on that word. What method can I use to
[quoted text clipped - 4 lines]
> Thanks,
> David
davidS - 18 Nov 2005 18:02 GMT
Thanks Tony.
I have a follow up question. Perhaps you can answer it.
I am trying to set a hyperlink on the word selected.
I would like the address of the hyperlink to be: "tables\the word
selected.sas"
For example
suppose the cursor was on the word "t_demog". I'd like to set the
address to
tables\t_demog.sas and the TextToDisplay to be t_demog.
I am trying to set a variable wdName to the text selected and then use
that
to set the address and the TextToDiplay.
See my code below.
Sub set_hyperlink()
'
' set_hyperlink Macro
' Macro recorded 11/18/2005 by David
'
Dim wdName As Characters
Selection.MoveEndUntil "., " & vbCr, wdForward
Set wdName = Selection.Copy
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
Address:="tables\" & "wdName" & ".sas" , SubAddress:="",
ScreenTip:="", _ TextToDisplay:="wdName"
End Sub
Tony Jollans - 18 Nov 2005 19:29 GMT
Hi David,
If you have the' word' selected then Selection.Text is a string value which
you can use directly or assign to a string variable if you wish.
--
Enjoy,
Tony
> Thanks Tony.
>
[quoted text clipped - 27 lines]
> ScreenTip:="", _ TextToDisplay:="wdName"
> End Sub