S
sprungli
Hello,
In a project I have a routine (thanks Chad DeMeyer) that finds a text and
then replaces it with a macrobutton displaying the same text. This happens
in a loop, as shown below.
Do While Selection.Find.Found
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:="MACROBUTTON MySub " +
Selection.Range, _
PreserveFormatting:=False
.Execute
Loop
Now, MySub (below) expects a string as a parameter and I want to pass the
value of Selection.Range (above) for each loop and then display this value
whenever the macrobutton is clicked.
Sub MySub(someTxt As String)
'do smt w/ the string param
MsgBox someTxt
End Sub
I do it with:
....
Text:="MACROBUTTON MySub(" + Selection.Range + ") " + Selection.Range
....
where the 1st Selection.Range is the parameter passed to MySub and the 2nd
one is the text displayed by the macrobutton.
As a result the macrobutton stops responding to clicks. Is there a
workaround this problem or I am trying to achieve something impossible?
Thank you in advance for any help.
In a project I have a routine (thanks Chad DeMeyer) that finds a text and
then replaces it with a macrobutton displaying the same text. This happens
in a loop, as shown below.
Do While Selection.Find.Found
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:="MACROBUTTON MySub " +
Selection.Range, _
PreserveFormatting:=False
.Execute
Loop
Now, MySub (below) expects a string as a parameter and I want to pass the
value of Selection.Range (above) for each loop and then display this value
whenever the macrobutton is clicked.
Sub MySub(someTxt As String)
'do smt w/ the string param
MsgBox someTxt
End Sub
I do it with:
....
Text:="MACROBUTTON MySub(" + Selection.Range + ") " + Selection.Range
....
where the 1st Selection.Range is the parameter passed to MySub and the 2nd
one is the text displayed by the macrobutton.
As a result the macrobutton stops responding to clicks. Is there a
workaround this problem or I am trying to achieve something impossible?
Thank you in advance for any help.