Reply
 
Thread Tools Display Modes
  #1   Report Post  
Judi
 
Posts: n/a
Default Want to programmatically Add formfields.

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



  #2   Report Post  
Jay Freedman
 
Posts: n/a
Default

Hi Judi,

There is a way to add more than 255 characters to a text form field. The
technique is described at
http://word.mvps.org/FAQs/MacrosVBA/...mFldResult.htm.

Trying to add form fields at run time is just going to get you into deeper
doodoo; don't go there.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Judi wrote:
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



  #3   Report Post  
Judi
 
Posts: n/a
Default

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!!!!
"Jay Freedman" wrote:

Hi Judi,

There is a way to add more than 255 characters to a text form field. The
technique is described at
http://word.mvps.org/FAQs/MacrosVBA/...mFldResult.htm.

Trying to add form fields at run time is just going to get you into deeper
doodoo; don't go there.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Judi wrote:
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




  #4   Report Post  
Judi
 
Posts: n/a
Default


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.


"Jay Freedman" wrote:

Hi Judi,

There is a way to add more than 255 characters to a text form field. The
technique is described at
http://word.mvps.org/FAQs/MacrosVBA/...mFldResult.htm.

Trying to add form fields at run time is just going to get you into deeper
doodoo; don't go there.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Judi wrote:
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




  #5   Report Post  
Jay Freedman
 
Posts: n/a
Default

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.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Judi wrote:
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.


"Jay Freedman" wrote:

Hi Judi,

There is a way to add more than 255 characters to a text form field.
The technique is described at
http://word.mvps.org/FAQs/MacrosVBA/...mFldResult.htm.

Trying to add form fields at run time is just going to get you into
deeper doodoo; don't go there.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Judi wrote:
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



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing htm Word files programmatically Ianb Microsoft Word Help 1 December 16th 04 10:33 PM
word 2000 - Stopping users formfields resetting in a form Anne Microsoft Word Help 1 December 15th 04 02:20 AM


All times are GMT +1. The time now is 11:35 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"