Benjamin_
01-18-2012, 07:24 AM
Hello,
i have a word document with many textboxes. Now i need the name of each textbox. (Textbox 1...n)
I've found the following Macro but it doesnt work..
Option Explicit
Option compare Text
Sub main()
Dim f As Field
Dim tb As TextBox
For Each f In ThisDocument.Fields
If f.OLEFormat Is Nothing Then ' do nothing
Else
If f.OLEFormat.ClassType = "Forms.Textbox.1" Then ' it is a textbox
Set tb = f.OLEFormat.Object
tb.Text = tb.Name
End If
End If ' f.oleformat is nothing
Next f
End Sub
Any Ideas ? I'm using Microsoft Word 2010
Thank you !
i have a word document with many textboxes. Now i need the name of each textbox. (Textbox 1...n)
I've found the following Macro but it doesnt work..
Option Explicit
Option compare Text
Sub main()
Dim f As Field
Dim tb As TextBox
For Each f In ThisDocument.Fields
If f.OLEFormat Is Nothing Then ' do nothing
Else
If f.OLEFormat.ClassType = "Forms.Textbox.1" Then ' it is a textbox
Set tb = f.OLEFormat.Object
tb.Text = tb.Name
End If
End If ' f.oleformat is nothing
Next f
End Sub
Any Ideas ? I'm using Microsoft Word 2010
Thank you !