Placement of data from several Userforms in a document  
Author Message
waltergd





PostPosted: Wed Aug 15 15:07:42 CDT 2007 Top

MS Word VBA >> Placement of data from several Userforms in a document

Who can give me some advice?

I created a template with several Userforms that are linked (you are
directed to the next Userform by clicking the Next button).

How can I gather al the info that a user types and put it in the document
when the last Userform is filled in and the user clicks the Ready button?

Thanks for your help/suggestions. No one in the Dutch User groups has given
any suggestion.

Ron

Word246  
 
 
Jay





PostPosted: Wed Aug 15 15:07:42 CDT 2007 Top

MS Word VBA >> Placement of data from several Userforms in a document Opinions vary, but here's mine:

In the template, define a document variable to hold each piece of data the
user will supply. (Document variables can be created only by VBA code; look
at the Help topic on the Variables collection.) In the body of the template,
insert DocVariable fields wherever necessary to display the values of the
variables. Note that you should assign a value, such as a space character,
when you define each variable; otherwise the DocVariable field will show an
error message.

In each userform, as the user clicks the button to go to the next one,
assign the values of the user's data to the proper document variables. When
the last userform is completed, its code should finish with

ActiveDocument.Fields.Update

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


> Who can give me some advice?
>
> I created a template with several Userforms that are linked (you are
> directed to the next Userform by clicking the Next button).
>
> How can I gather al the info that a user types and put it in the
> document when the last Userform is filled in and the user clicks the
> Ready button?
>
> Thanks for your help/suggestions. No one in the Dutch User groups has
> given any suggestion.
>
> Ron


 
 
RoBo





PostPosted: Wed Aug 15 15:28:04 CDT 2007 Top

MS Word VBA >> Placement of data from several Userforms in a document Hello Jay,

The template already has bookmarks defined with variable names. Will this
work too or do I have to create fields using the Insert, Field menu in Word
2003?

Ron



> Opinions vary, but here's mine:
>
> In the template, define a document variable to hold each piece of data the
> user will supply. (Document variables can be created only by VBA code; look
> at the Help topic on the Variables collection.) In the body of the template,
> insert DocVariable fields wherever necessary to display the values of the
> variables. Note that you should assign a value, such as a space character,
> when you define each variable; otherwise the DocVariable field will show an
> error message.
>
> In each userform, as the user clicks the button to go to the next one,
> assign the values of the user's data to the proper document variables. When
> the last userform is completed, its code should finish with
>
> ActiveDocument.Fields.Update
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.
>

> > Who can give me some advice?
> >
> > I created a template with several Userforms that are linked (you are
> > directed to the next Userform by clicking the Next button).
> >
> > How can I gather al the info that a user types and put it in the
> > document when the last Userform is filled in and the user clicks the
> > Ready button?
> >
> > Thanks for your help/suggestions. No one in the Dutch User groups has
> > given any suggestion.
> >
> > Ron
>
>
>
 
 
Jay





PostPosted: Wed Aug 15 15:39:25 CDT 2007 Top

MS Word VBA >> Placement of data from several Userforms in a document You can use the bookmarks, but the code in the userforms will have to be
different. Look at this article:
http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.

Another consideration: If you use document variables and DocVariable fields,
you can have two or more fields that display the same variable's value --
you just insert the same field in multiple places. When you use bookmarks,
each bookmark must have a unique name; if you want to repeat a value
elsewhere in the document, you have to use a REF field or a cross-reference
to the bookmark.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


> Hello Jay,
>
> The template already has bookmarks defined with variable names. Will
> this work too or do I have to create fields using the Insert, Field
> menu in Word 2003?
>
> Ron
>

>
>> Opinions vary, but here's mine:
>>
>> In the template, define a document variable to hold each piece of
>> data the user will supply. (Document variables can be created only
>> by VBA code; look at the Help topic on the Variables collection.) In
>> the body of the template, insert DocVariable fields wherever
>> necessary to display the values of the variables. Note that you
>> should assign a value, such as a space character, when you define
>> each variable; otherwise the DocVariable field will show an error
>> message.
>>
>> In each userform, as the user clicks the button to go to the next
>> one, assign the values of the user's data to the proper document
>> variables. When the last userform is completed, its code should
>> finish with
>>
>> ActiveDocument.Fields.Update
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
>>

>>> Who can give me some advice?
>>>
>>> I created a template with several Userforms that are linked (you are
>>> directed to the next Userform by clicking the Next button).
>>>
>>> How can I gather al the info that a user types and put it in the
>>> document when the last Userform is filled in and the user clicks the
>>> Ready button?
>>>
>>> Thanks for your help/suggestions. No one in the Dutch User groups
>>> has given any suggestion.
>>>
>>> Ron


 
 
RoBo





PostPosted: Wed Aug 15 15:52:07 CDT 2007 Top

MS Word VBA >> Placement of data from several Userforms in a document Thanks Jay,

This will most certainly help. Tomorrow I'll implement this and let you know
the results.

Ron



> You can use the bookmarks, but the code in the userforms will have to be
> different. Look at this article:
> http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.
>
> Another consideration: If you use document variables and DocVariable fields,
> you can have two or more fields that display the same variable's value --
> you just insert the same field in multiple places. When you use bookmarks,
> each bookmark must have a unique name; if you want to repeat a value
> elsewhere in the document, you have to use a REF field or a cross-reference
> to the bookmark.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.
>

> > Hello Jay,
> >
> > The template already has bookmarks defined with variable names. Will
> > this work too or do I have to create fields using the Insert, Field
> > menu in Word 2003?
> >
> > Ron
> >

> >
> >> Opinions vary, but here's mine:
> >>
> >> In the template, define a document variable to hold each piece of
> >> data the user will supply. (Document variables can be created only
> >> by VBA code; look at the Help topic on the Variables collection.) In
> >> the body of the template, insert DocVariable fields wherever
> >> necessary to display the values of the variables. Note that you
> >> should assign a value, such as a space character, when you define
> >> each variable; otherwise the DocVariable field will show an error
> >> message.
> >>
> >> In each userform, as the user clicks the button to go to the next
> >> one, assign the values of the user's data to the proper document
> >> variables. When the last userform is completed, its code should
> >> finish with
> >>
> >> ActiveDocument.Fields.Update
> >>
> >> --
> >> Regards,
> >> Jay Freedman
> >> Microsoft Word MVP FAQ: http://word.mvps.org
> >> Email cannot be acknowledged; please post all follow-ups to the
> >> newsgroup so all may benefit.
> >>

> >>> Who can give me some advice?
> >>>
> >>> I created a template with several Userforms that are linked (you are
> >>> directed to the next Userform by clicking the Next button).
> >>>
> >>> How can I gather al the info that a user types and put it in the
> >>> document when the last Userform is filled in and the user clicks the
> >>> Ready button?
> >>>
> >>> Thanks for your help/suggestions. No one in the Dutch User groups
> >>> has given any suggestion.
> >>>
> >>> Ron
>
>
>
 
 
msteckler





PostPosted: Thu Oct 18 15:10:00 PDT 2007 Top

MS Word VBA >> Placement of data from several Userforms in a document Hello!

I have implemented a similar template. The user enters data in a UserForm,
and then I use :
Private Sub CommandButton3_Click()
With ActiveDocument
.Bookmarks("apartname").Range _
.InsertBefore apartname
End With
ActiveDocument.Fields.Update
UserForm4.Hide

However, the REF fields are NOT being shown in the resulting document. I
have linked them to their respective bookmark, tried updating, but nothing
works.

Any ideas on how this can work?

If this is the worst method, can you recommend a way to use
DocVariables/Properties that will work?

Thank you.






> Thanks Jay,
>
> This will most certainly help. Tomorrow I'll implement this and let you know
> the results.
>
> Ron
>

>
> > You can use the bookmarks, but the code in the userforms will have to be
> > different. Look at this article:
> > http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.
> >
> > Another consideration: If you use document variables and DocVariable fields,
> > you can have two or more fields that display the same variable's value --
> > you just insert the same field in multiple places. When you use bookmarks,
> > each bookmark must have a unique name; if you want to repeat a value
> > elsewhere in the document, you have to use a REF field or a cross-reference
> > to the bookmark.
> >
> > --
> > Regards,
> > Jay Freedman
> > Microsoft Word MVP FAQ: http://word.mvps.org
> > Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> > all may benefit.
> >

> > > Hello Jay,
> > >
> > > The template already has bookmarks defined with variable names. Will
> > > this work too or do I have to create fields using the Insert, Field
> > > menu in Word 2003?
> > >
> > > Ron
> > >

> > >
> > >> Opinions vary, but here's mine:
> > >>
> > >> In the template, define a document variable to hold each piece of
> > >> data the user will supply. (Document variables can be created only
> > >> by VBA code; look at the Help topic on the Variables collection.) In
> > >> the body of the template, insert DocVariable fields wherever
> > >> necessary to display the values of the variables. Note that you
> > >> should assign a value, such as a space character, when you define
> > >> each variable; otherwise the DocVariable field will show an error
> > >> message.
> > >>
> > >> In each userform, as the user clicks the button to go to the next
> > >> one, assign the values of the user's data to the proper document
> > >> variables. When the last userform is completed, its code should
> > >> finish with
> > >>
> > >> ActiveDocument.Fields.Update
> > >>
> > >> --
> > >> Regards,
> > >> Jay Freedman
> > >> Microsoft Word MVP FAQ: http://word.mvps.org
> > >> Email cannot be acknowledged; please post all follow-ups to the
> > >> newsgroup so all may benefit.
> > >>

> > >>> Who can give me some advice?
> > >>>
> > >>> I created a template with several Userforms that are linked (you are
> > >>> directed to the next Userform by clicking the Next button).
> > >>>
> > >>> How can I gather al the info that a user types and put it in the
> > >>> document when the last Userform is filled in and the user clicks the
> > >>> Ready button?
> > >>>
> > >>> Thanks for your help/suggestions. No one in the Dutch User groups
> > >>> has given any suggestion.
> > >>>
> > >>> Ron
> >
> >
> >