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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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