Hi mlsrinivas
I'm assuming you want to update TextBoxes that already exist, not create new
TextBoxes. Here's some code that should help:
Public Sub AddTextToTextBox()
Dim shrItem As Word.Shape
Dim lngShape As Long
' Iterate all Shapes in the ShapeRange object
With ActiveDocument.Range.ShapeRange
For lngShape = 1 To .Count
Set shrItem = .Item(lngShape)
' We're only interested in TextBoxes
If shrItem.Type = msoTextBox Then
shrItem.TextFrame.TextRange.Text = "hello world"
End If
Next
End With
End Sub
Note: Shapes can be grouped, this code wont update a grouped TextBox. You may
need to identify a specific TextBox (otherwise how do you know which TextBox
you're stuffing text into?). The easiest way to do this is to set the shapes
name, something like this:
ActiveDocument.Range.ShapeRange(1).Name = "TB_Name"
HTH + Cheers - Peter