ActiveX textbox value

寵の児 提交于 2019-12-30 09:52:57

问题


How do I get the value of a textbox in Word? I know in excel this is the right syntax: ActiveSheet.Shapes(x).Name.

I thought in word this would be the right syntax
ActiveDocument.Shapes(x).Name,
but this doesn't seems to work.

With this piece of code I also couldn't find a textbox:

For i = 1 To ActiveDocument.Shapes.Count
    MsgBox ActiveDocument.Shapes(i).Name
Next i

回答1:


  1. To get the value of a standard textbox, use this: ActiveDocument.Shapes(1).TextFrame.TextRange.Text

  2. To get the value of ActiveX controls (OLEobjects), use this syntax where TextBox1 is the control name, use ActiveDocument.TextBox1.Value

  3. To get the name of ActiveX controls, use this: ActiveDocument.InlineShapes(1).OLEFormat.Object.Name




回答2:


I used tags (object properties -> assign a tag name) to edit the object's value. Use this syntax to change the value of a content control: ActiveDocument.SelectContentControlsByTag("Your-Content-Control-Tag").Item(1).Range.Text = "your-preferred-value" Anyway, thanks Rachel Hettinger for your patience ;).



来源:https://stackoverflow.com/questions/8638022/activex-textbox-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!