Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveX textbox value

Tags:

ms-word

vba

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
like image 945
jroeleveld Avatar asked Dec 26 '11 18:12

jroeleveld


1 Answers

  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

like image 160
Rachel Hettinger Avatar answered Sep 28 '22 09:09

Rachel Hettinger