using textfields and VBA

J

John Devlon

Hi,

I've created a word-file with a few textfields from the Toolbox controls.

Does anyone know how to get the value of these fields using VBA ?

ThisDocument.form("txtName").Result

.... does not work


Thanx

John
 
H

Helmut Weber

Hi John,
I doubt whether this has to be that complicated.
And I'm assuming, that your textfields are inlineshapes, not shapes.
Otherwise repeat all using shape instead of inlineshape.
Until someone else comes up with a better solution...

Sub Makro4()
Dim oShp As InlineShape
For Each oShp In ActiveDocument.InlineShapes
If oShp.Type = wdInlineShapeOLEControlObject Then
If oShp.OLEFormat.ClassType = "Forms.TextBox.1" Then
MsgBox oShp.OLEFormat.Object.Name
MsgBox oShp.OLEFormat.Object.Value
End If
End If
Next
End Sub

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

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