Want to programmatically Add formfields.

J

Judi

I am sorry I am asking this question, but I have search until I'm blue in the
face for an answer.
I have an application which populates fields on a Template with data from
another application.
I read each field by doing a

Forall bk in Worddoc.formfields
......using formfield name find corresponding value in other database,
..... populate formfield by WordDoc.FormFields(bk.Name).Result = fldValue
Loop (next or whatever)

SOME of the fields in the other database contain text data that is GREATER
than 255 chars. The target formfield will not allow #chars over 255.
Unless there is a solution to this (we're on Office 2000) I want to be able
to dynamically Insert a number of formfields for the extra characters AND I
also want to be able to REMOVE all of them (Except the 1st one) and Re-add
them if the user reloads that document. ( The document is a contract and
therefore needs to be updated with data from the database AND once modified,
Re-updated from the database.)

I have also tried having a Start Formfield and an End Formfield and just
insert text after the first formfield. But when updating the document I'm
having trouble removing the text without remvoing the form fields also.


I have tried bookmarks, but that doesn't work either.

Assistance would be GREATLY APPRECIATED.

Sincerely,
Judi Mohler
(e-mail address removed)
 
J

Judi

JAY!! THANK YOU THANK YOU!! I will go try. I'm a little worried about the
wdAllowOnlyFormFields, since I am accessing via OLE interface. May need the
actual "integer code" instead, don't know. THANKS!!!!
 
J

Judi

I get a SYNTAX error when trying to compile my code on:
WordDoc.ProtectType:=wdAllowOnlyFormFields, NoReset:=True

Again, I am accessing through OLE. Is there another way to pass these
properties?
Darn, I'm so close.
 
J

Jay Freedman

Hi Judi,

You can replace wdAllowOnlyFormFields with the value 2.

In Word's VBA editor, you can use the Object Browser to find the values of
VBA constants. (For completeness, the other valid values of Type are
wdAllowOnlyRevisions = 0, wdAllowOnlyComments = 1, and wdAllowOnlyReading =
3.) Depending on the language of the application you're writing, you could
use a #define or Const statement to declare the constant's value at the top
of your code and not have to change the Protect statement.
 

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