I'm trying to create a set of nested textboxes in Word 2010. I can do it using the UI, but I need to be able to do this programmatically. What I'm trying to do is to create the 'main' text box (called QuestionBox), and then after adding some text (QuestionText) to create some textboxes inside the QuestionBox (let's call them ResponseBox1 .. ResponseBox3. Each of ResponseBox contains text, possibly on more than one line.
I also want to be able to add a shape outside the response box, but inside the QuestionBox - the shape is either a small circle or a small square. (Yes - they are replacements for a RadioButton and a CheckBox ;-)
So far I have VBA code that (seems to) create the QuestionBox, but there is nothing visible - even if I set the visible attribute to true.
Sub TextCreateTextBoxes()
Dim TxtBox As Shape
Set TxtBox = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 0.5, 0.5, 6#, 2#)
TxtBox.Line.Weight = 2
TxtBox.Line.ForeColor = RGB(0, 0, 0)
TxtBox.Visible = True
End Sub
This is incredibly frustrating, as I can't even use Macro Recorder to record the steps of creating and formatting the text box. I turn on recording, and end up with the following (pretty useless, but syntactically perfect) code:
Sub InsertTextBox()
'
' InsertTextBox Macro
'
'
End Sub
Any takers?
Thanks,
Tony
Bookmarks