Need to speed up formfield data retrieval

D

dziv

I have a complex "protected" Word form that contains data
in numerous bookmarked form fields. I am currently
retrieving and setting the data with the following code:

Retrieve:

Private Function GetStr(TempStr$) As String

GetStr = ActiveDocument.FormFields(TempStr$).Result

End Function


Set:

Private Sub SetBK(TempStr$, vVar As Variant)

ActiveDocument.FormFields(TempStr$).Result = vVar

End Sub

Does anyone know of a faster way to retrieve and set data
in form fields? It is excruciatingly slow!

I'd prefer not to retrieve data with the cell range, as
this complicates matters if someone needs to add/remove
rows from the table. Thanks.
 
C

Charles Kenyon

Word formfields inserted manually automatically have bookmarks. You don't
need to be inserting them. If you are inserting them with code, you can set
the bookmark as part of the code that inserts the formfield.

ActiveDocument.FormFields(index).Result seems effective for me in obtaining
or setting formfield results. index can be either a string with the bookmark
name for the field or a number.
 
D

dziv

Thanks, Charles. I guess I wasn't clear about the bookmarks - they are set within the formfield. So, when it automatically calles it Text1, etc. I change the name to what I need. I am not duplicating the effort

I'm just wondering if there is some alternate code to extracting the formfield info. than ActiveDocument.Formfields(bookmarkname).Result

Thanks
 
C

Charles Kenyon

There is no other way that I know about, but that doesn't mean there is no
other way.

If you are getting all of them or a special set, how about cycling through
the formfields collection using an array to hold values? I've never tried
getting / setting large numbers of formfields at a time, I think the max
I've done was about 12 and that worked OK.


dziv said:
Thanks, Charles. I guess I wasn't clear about the bookmarks - they are
set within the formfield. So, when it automatically calles it Text1, etc. I
change the name to what I need. I am not duplicating the effort.
I'm just wondering if there is some alternate code to extracting the
formfield info. than ActiveDocument.Formfields(bookmarkname).Result.
 

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