How to add to the selected word MacroButton field with text of thisword?

A

avkokin

Hello.
I select any word and then add to it the bookmark. Next I should by
double-click on this selected word and this action should open my own
form (UserForm). I think I should use MacroButton field.
Question: how to do it programmatically? How to add to the selected
word MacroButton field with text of this word?
 
G

Graham Mayor

The following will create a macrobutton field with selected text as user
prompt to call the macro named at Macroname

Dim MacroName As String
MacroName = "Macroname"
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:="MACROBUTTON " & MacroName & Chr(32) & Selection.Text, _
PreserveFormatting:=False

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Top