更新中MACROBUTTON文本displaid在MS Word
我使用MACROBUTTON在VBA中有一个字段的值是通过访问其他系统的计算,在同一时间,我希望能在那场双击指定用于从中检索数据的一些设置其他系统。
I am using macrobutton in VBA to have a field whose value is calculated by accessing some other system, and at the same time, I want to be able to double-click on that field to specify some settings used to retrieve data from that other system.
整个宏观的东西工作正常,但我无法弄清楚如何改变对MACROBUTTON的标签。
The whole macro stuff works fine but I can not figure out how to change the label on the macrobutton.
通常情况下,MACROBUTTON看起来像这样{MACROBUTTON MACRO_NAME标签{some_arg} {some_arg2}}
Typically the macrobutton looks like this { MACROBUTTON macro_name label {some_arg}{some_arg2} }
我试过访问selection.fields(1)code.text甚至做正则表达式用别的东西来代替标签,但只是不工作,即任我失去了ARGS或者我搞砸了标签
I tried accessing selection.fields(1).code.text and even doing regexp to replace 'label' by something else but that just does not work, i.e. either I lose the args or I screw up the label.
对于这个问题,或者一些其它类型的字段的建议,我可以用它来实现这一目标的任何建议吗?我不介意使用DOCVARIABLE但这些不能响应点击并进行论证?
Any advice for this issue, or perhaps a suggestion of some other type of field I could use to achieve this? I wouldn't mind using DOCVARIABLE but these can not respond to clicks and carry arguments?
您应该能够做这样的事:
You should be able to do something like this:
Sub Testit1()
Dim strText As String
Dim strLabel As String
Dim strNewLabel As String
strLabel = "Chew"
strNewLabel = "Devour"
' Replace the field code values in the first field to change the label
strText = ActiveDocument.Fields(1).Code.Text
ActiveDocument.Fields(1).Code.Text = Replace(strText, strLabel, strNewLabel)
End Sub
这基本上都会做搜索和现场code你想改变MACROBUTTON字段中替换。 ActiveDocument.Fields(1)code.Text
是我认为你正在寻找的一部分。
This will basically do a search and replace inside the field code for the macrobutton field you want to change. ActiveDocument.Fields(1).Code.Text
is the part I think you are looking for.