populate textboxes

S

Sandy

Hi,
I have 21 textboxes in a document (Ms Word 2003), all have the same content
e.g. £1.50 since they are intended as pricing labels.
I would like to have a macro insert the price to each textbox rather than
have to manually change each one. I am not familiar with word macros.
The following is my initial thought on the process.

Sub InsertNewPrice()
Dim strAmount as String
Dim tBox as TextBox

strAmount=InputBox("Enter new price", "Pricing Labels")

For Each tBox in Document
tBox.text = strAmount
Next

End Sub

Am I even close?
Any help would be appreciated.

Sandy
 
G

Greg Maxey

Sub ScratchMaco()
Dim oShape As Word.Shape
Dim sAmount As String
sAmount = InputBox("Enter the price", "Price")
For Each oShape In ActiveDocument.Shapes
If oShape.Type = msoTextBox Then
oShape.TextFrame.TextRange = "$" & sAmount
End If
Next oShape
End Sub
 
S

Sandy

Excellent Greg
Thank you very much

Greg Maxey said:
Sub ScratchMaco()
Dim oShape As Word.Shape
Dim sAmount As String
sAmount = InputBox("Enter the price", "Price")
For Each oShape In ActiveDocument.Shapes
If oShape.Type = msoTextBox Then
oShape.TextFrame.TextRange = "$" & sAmount
End If
Next oShape
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top