Bonjour,
Dans son message, < David Hodgkins > écrivait :
In this message, < David Hodgkins > wrote:
|| Thanks you, but alas, no. When I run it nothing is picked up. There is no
|| form on the document. The textbox is pulled directly off the toolbox and
|| placed on the document.
||
In your first post you wrote:
<quote>
I have a word document with several textbox fields
<end quote>
So I assumed they were form fields...
Now you are writing:
<quote>
The textbox is pulled directly off the toolbox
<end quote>
You mean the ActiveX Control toolbar?
If they were from the Control Toolbar, try this:
'_______________________________________
Sub GetTextBoxName()
Dim myObj As Field
Dim ObjNames As String
Dim i As Long
Dim ResultDoc As Document
Dim SourceDoc As Document
Set SourceDoc = ActiveDocument
i = 0
For Each myObj In SourceDoc.Fields
With myObj
If Not InStr(1, .Code, "Forms.TextBox.1") = 0 Then
i = i + 1
ObjNames = ObjNames & .OLEFormat.Object.Name & Chr(13)
End If
End With
Next myObj
Set ResultDoc = Documents.Add
With ResultDoc
.Range.Text = "There are " & i & " textbox controls " _
& " in """ & SourceDoc.Name & ".""" & Chr(13) & Chr(13) _
& "Here are their names:" & Chr(13) & Chr(13) _
& ObjNames
End With
End Sub
'_______________________________________
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org