Retrieving Data from forms

W

wphx

I have received a number of documents, which have fields embedded in the
form, and then protected.

I want to be able to extract the data entered into these forms.

I have done some Access programming to read the formfields collection,
however, some fields have been created with no field names, and they don't
appear in the collection. Is there some way of reaching that data using VBA?

Thanks if you can help.
 
P

Peter Jamieson

A simple experiment here suggests that

Sub ListFormFields()
Dim oFormField As Word.FormField
For Each oFormField In ActiveDocument.FormFields
Debug.Print oFormField.Type, oFormField.Result
Next
End Sub

lists all the types and results, even when the field names are blank. This
is in Word 2000. So...
a. Are you using similar code?
b. which version of Word?

An alternative might be to programmatically set Tools|Options|Save|"Save
data only for forms" then save the form, then open the resulting .csv file
using VBA OPEN (or otherwise), read the data and save it in your database.
 
W

wphx

I think I've found my way through this.

Using access, I had first tried using the formfield names to create the
access table fields - however, there were duplicates and errors.

second, I created a tranlastion table - one field containing the word field
name and the second containing a unique access field name (generated from
the word field name)

I then walked through the formfields() collection, and sequentially grabbed
the access field name from the translation table.

I was able then to create the table and write the data into the appropriate
fields.

I had tried renaming the field names in the source document programattically
but it got into a tangle with the duplicate field names.

Anyhow, your reply has borne up what I found out that if I just scan thru
the collection, I can bypass referencing the field by its name.

Thanks again
 

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