Reading Field Forms w/ Blank Bookmarks

E

expect_ed

My office has several hundred copies of a Word form that has been populated
over the past year as a way of tracking individual projects. Each form has a
couple dozen fields, most of which have bookmarks but a few which have the
bookmark field blank. I would like to retrieve and consolidate the data in
the fields and I found Greg Maxey's macro to do this into Access. Is it
possible to do this for the form fields that do not have a bookmark valule?
Thanks in advance for any help.
ed
 
M

macropod

Hi expect_ed,

Provided all the documents have the same layout and number of formfields (ie there's no gaps in or extras added to the set of
fields), you can extract the data by simply iterating through the formfield collection. You don't need to know the bookmark names
unless you're after a particular formfield and you don't want to have to remember its position in the document. For example:

Sub Demo()
Dim oFld As FormField
With ActiveDocument
For Each oFld In .FormFields
MsgBox oFld.Result
Next oFld
End With
End Sub

For checkbox formfields, the 'result' will be 1 (True) or 0 (False). Obviously, you'll need to replace the messagebox with the
relevant output code and call the above routine from whatever code you're using to loop through the documents.
 
E

expect_ed

Thanks, this is a big help.
Only problem is, if the formfield is blank I get the error:

Run-time error '5825': Object has been deleted.

Seems I need some sort of error capturing/ignoring routine there but I have
no idea how to start setting one up.
Any help appreciated.
ed

macropod said:
Hi expect_ed,

Provided all the documents have the same layout and number of formfields (ie there's no gaps in or extras added to the set of
fields), you can extract the data by simply iterating through the formfield collection. You don't need to know the bookmark names
unless you're after a particular formfield and you don't want to have to remember its position in the document. For example:

Sub Demo()
Dim oFld As FormField
With ActiveDocument
For Each oFld In .FormFields
MsgBox oFld.Result
Next oFld
End With
End Sub

For checkbox formfields, the 'result' will be 1 (True) or 0 (False). Obviously, you'll need to replace the messagebox with the
relevant output code and call the above routine from whatever code you're using to loop through the documents.

--
Cheers
macropod
[Microsoft MVP - Word]


expect_ed said:
My office has several hundred copies of a Word form that has been populated
over the past year as a way of tracking individual projects. Each form has a
couple dozen fields, most of which have bookmarks but a few which have the
bookmark field blank. I would like to retrieve and consolidate the data in
the fields and I found Greg Maxey's macro to do this into Access. Is it
possible to do this for the form fields that do not have a bookmark valule?
Thanks in advance for any help.
ed
 
M

macropod

Hi expect_ed,

I'm unable to reproduce that behaviour, even if the formfield is blank. What type of formfield? Is it located in a textbox, table or
a normal paragraph?

--
Cheers
macropod
[Microsoft MVP - Word]


expect_ed said:
Thanks, this is a big help.
Only problem is, if the formfield is blank I get the error:

Run-time error '5825': Object has been deleted.

Seems I need some sort of error capturing/ignoring routine there but I have
no idea how to start setting one up.
Any help appreciated.
ed

macropod said:
Hi expect_ed,

Provided all the documents have the same layout and number of formfields (ie there's no gaps in or extras added to the set of
fields), you can extract the data by simply iterating through the formfield collection. You don't need to know the bookmark names
unless you're after a particular formfield and you don't want to have to remember its position in the document. For example:

Sub Demo()
Dim oFld As FormField
With ActiveDocument
For Each oFld In .FormFields
MsgBox oFld.Result
Next oFld
End With
End Sub

For checkbox formfields, the 'result' will be 1 (True) or 0 (False). Obviously, you'll need to replace the messagebox with the
relevant output code and call the above routine from whatever code you're using to loop through the documents.

--
Cheers
macropod
[Microsoft MVP - Word]


expect_ed said:
My office has several hundred copies of a Word form that has been populated
over the past year as a way of tracking individual projects. Each form has a
couple dozen fields, most of which have bookmarks but a few which have the
bookmark field blank. I would like to retrieve and consolidate the data in
the fields and I found Greg Maxey's macro to do this into Access. Is it
possible to do this for the form fields that do not have a bookmark valule?
Thanks in advance for any help.
ed
 
E

expect_ed

The one I happened to be a date field, or rather Text Form Field of type
Date. Unlimited length formatted MM/dd/yyyy and bookmarked as Text 24. What
is strange is that when viewing the form the field is only about the width of
a period. If I enter a date and then delete it I cannot get it to go back
to the same state. Rather it shows the normal circles of a more typical
entry field. Not sure how it got that way but I managed to work around it by
adding an "On Error Resume Next" command at the point between setting temp =
oFld.Result and Range("A2").Offset(x,y) = temp.
macropod said:
Hi expect_ed,

I'm unable to reproduce that behaviour, even if the formfield is blank. What type of formfield? Is it located in a textbox, table or
a normal paragraph?

--
Cheers
macropod
[Microsoft MVP - Word]


expect_ed said:
Thanks, this is a big help.
Only problem is, if the formfield is blank I get the error:

Run-time error '5825': Object has been deleted.

Seems I need some sort of error capturing/ignoring routine there but I have
no idea how to start setting one up.
Any help appreciated.
ed

macropod said:
Hi expect_ed,

Provided all the documents have the same layout and number of formfields (ie there's no gaps in or extras added to the set of
fields), you can extract the data by simply iterating through the formfield collection. You don't need to know the bookmark names
unless you're after a particular formfield and you don't want to have to remember its position in the document. For example:

Sub Demo()
Dim oFld As FormField
With ActiveDocument
For Each oFld In .FormFields
MsgBox oFld.Result
Next oFld
End With
End Sub

For checkbox formfields, the 'result' will be 1 (True) or 0 (False). Obviously, you'll need to replace the messagebox with the
relevant output code and call the above routine from whatever code you're using to loop through the documents.

--
Cheers
macropod
[Microsoft MVP - Word]


My office has several hundred copies of a Word form that has been populated
over the past year as a way of tracking individual projects. Each form has a
couple dozen fields, most of which have bookmarks but a few which have the
bookmark field blank. I would like to retrieve and consolidate the data in
the fields and I found Greg Maxey's macro to do this into Access. Is it
possible to do this for the form fields that do not have a bookmark valule?
Thanks in advance for any help.
ed
 
M

macropod

Hi expect_ed,

With 'On Error Resume Next', be aware that may mean the rest of the collected data will be offset by one position from where it
should be. Better to build in an error-handling routine that deals with the errors more gracefully than that.

--
Cheers
macropod
[Microsoft MVP - Word]


expect_ed said:
The one I happened to be a date field, or rather Text Form Field of type
Date. Unlimited length formatted MM/dd/yyyy and bookmarked as Text 24. What
is strange is that when viewing the form the field is only about the width of
a period. If I enter a date and then delete it I cannot get it to go back
to the same state. Rather it shows the normal circles of a more typical
entry field. Not sure how it got that way but I managed to work around it by
adding an "On Error Resume Next" command at the point between setting temp =
oFld.Result and Range("A2").Offset(x,y) = temp.
macropod said:
Hi expect_ed,

I'm unable to reproduce that behaviour, even if the formfield is blank. What type of formfield? Is it located in a textbox, table
or
a normal paragraph?

--
Cheers
macropod
[Microsoft MVP - Word]


expect_ed said:
Thanks, this is a big help.
Only problem is, if the formfield is blank I get the error:

Run-time error '5825': Object has been deleted.

Seems I need some sort of error capturing/ignoring routine there but I have
no idea how to start setting one up.
Any help appreciated.
ed

:

Hi expect_ed,

Provided all the documents have the same layout and number of formfields (ie there's no gaps in or extras added to the set of
fields), you can extract the data by simply iterating through the formfield collection. You don't need to know the bookmark
names
unless you're after a particular formfield and you don't want to have to remember its position in the document. For example:

Sub Demo()
Dim oFld As FormField
With ActiveDocument
For Each oFld In .FormFields
MsgBox oFld.Result
Next oFld
End With
End Sub

For checkbox formfields, the 'result' will be 1 (True) or 0 (False). Obviously, you'll need to replace the messagebox with the
relevant output code and call the above routine from whatever code you're using to loop through the documents.

--
Cheers
macropod
[Microsoft MVP - Word]


My office has several hundred copies of a Word form that has been populated
over the past year as a way of tracking individual projects. Each form has a
couple dozen fields, most of which have bookmarks but a few which have the
bookmark field blank. I would like to retrieve and consolidate the data in
the fields and I found Greg Maxey's macro to do this into Access. Is it
possible to do this for the form fields that do not have a bookmark valule?
Thanks in advance for any help.
ed
 

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