Naming text boxes 
Author Message
 Naming text boxes

Hi,

is there a possibility to give each textbox in a word-document a name and
reference it from VBA throug this specific name?
If not: what other possibilities do i have to find the textbox which i want?

thanks in advance,
Reto



Wed, 29 Oct 2003 02:07:11 GMT  
 Naming text boxes
Reto,

Yes, just use the .Name property:

Sub TextBoxNamerDemo
Dim x As Shape, y As Shape
Set x= ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
   100, 70, 30, 30)
Set y= ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
   150, 70, 30, 30)
x.Name = "Xbox"
y.Name = "Ybox"
MsgBox "Document now has two textboxes."
ActiveDocument.Shapes("Xbox").Delete
MsgBox "First box now gone."
End Sub


------ WWW: http://www.speakeasy.org/~mtangard ----------------------
------------- "Life is nothing if you aren't obsessed." --John Waters
---------------------------------------------------------------------

Quote:

> Hi,

> is there a possibility to give each textbox in a word-document a name and
> reference it from VBA throug this specific name?
> If not: what other possibilities do i have to find the textbox which i want?

> thanks in advance,
> Reto



Wed, 29 Oct 2003 08:02:04 GMT  
 Naming text boxes
hi !

to get all textboxes try this:

Sub Test_TextBoxes()

  Dim shp    As Shape

  For Each shp In ActiveDocument.Shapes
    If shp.Type = msoTextBox Then
      Debug.Print shp.Name
      Debug.Print shp.TextFrame.TextRange.Text
    End If
  Next shp

End Sub

regards, mic



Thu, 30 Oct 2003 01:15:01 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Request.Form on dynamically named text boxes

2. Creating text box name based on rs.fields(x).name

3. Creating text box name based on rs.fields(x).name

4. Reading file name from text box and/or File List Box

5. Text box text on new page text box

6. Using Contents of text box on form for Table name

7. Displays #Name error in text box only when printing

8. Populating a text box with the user name

9. Finding the name of a text box

10. Text Box Name

11. Finding / Naming a text box

12. Adding named formfield text boxes programatically

 

 
Powered by phpBB® Forum Software