Auto Insert Text 
Author Message
 Auto Insert Text

Hi,

I'm looking to create a document template that opens a
user form when a new document is created (got this far at
least). From there I want to be able to fill in some text
boxes, click and button and hey presto all the information
i filled in is transferred to the document in the relevant
places ready for printing, like an on the fly mail merge.

Unfortunately I can't figure out how to get this to work.
I've been playing around with creating bookmarks and then
setting  fields to reference them but this creates the
bookmarks in random places and I wouild prefer to either
have them hidden or not use then at all if there is
another way.

Any help would be greatly appreciated.

Thanks

Martin



Mon, 05 Dec 2005 19:18:06 GMT  
 Auto Insert Text
Hi Martin,

If you located the bookmarks in the template in the locations where you want
the data to appear and then in a Command Button Click event in the UserForm,
you use:

ActiveDocument.Bookmarks("bookmarkname").Range.InsertBefore [Reference to
respective control on the userform].Text

The data entered into that control will be inserted into the bookmark.

This method is detailed in the article "How to create a Userform" at:

http://www.mvps.org/word/FAQs/Userforms/CreateAUserForm.htm

You would only use a {REF} field if you wanted the same information in two
places in which case, the { REF } field in the second location would refer
to the text of the first bookmark.  With this method, it will be necessary
to use an

ActiveDocument.Fields.Update

command in the code to get the cross references to update.

You could also just use a second bookmark (the names have be unique though)
and use code such as the above to insert the data from the form directly
into the second bookmark.

Another alternative is to have the command button create DocumentVariables
containing the data from the controls on the form and in the template have
{ DOCVARIABLE } fields where you want the data to appear.

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP

Quote:
> Hi,

> I'm looking to create a document template that opens a
> user form when a new document is created (got this far at
> least). From there I want to be able to fill in some text
> boxes, click and button and hey presto all the information
> i filled in is transferred to the document in the relevant
> places ready for printing, like an on the fly mail merge.

> Unfortunately I can't figure out how to get this to work.
> I've been playing around with creating bookmarks and then
> setting  fields to reference them but this creates the
> bookmarks in random places and I wouild prefer to either
> have them hidden or not use then at all if there is
> another way.

> Any help would be greatly appreciated.

> Thanks

> Martin



Mon, 05 Dec 2005 20:32:35 GMT  
 Auto Insert Text
Hi Doug,

Thanks for you help. This is basically what I was trying
before but I didn't have the options set to show bookmarks
which is why it looked like random placement to me. The
article you recommended seems to cover everything I need.

Thanks again

Martin

Quote:
>-----Original Message-----
>Hi Martin,

>If you located the bookmarks in the template in the

locations where you want
Quote:
>the data to appear and then in a Command Button Click

event in the UserForm,
Quote:
>you use:

>ActiveDocument.Bookmarks

("bookmarkname").Range.InsertBefore [Reference to
Quote:
>respective control on the userform].Text

>The data entered into that control will be inserted into
the bookmark.

>This method is detailed in the article "How to create a
Userform" at:

>http://www.mvps.org/word/FAQs/Userforms/CreateAUserForm.ht
m

>You would only use a {REF} field if you wanted the same
information in two
>places in which case, the { REF } field in the second

location would refer
Quote:
>to the text of the first bookmark.  With this method, it
will be necessary
>to use an

>ActiveDocument.Fields.Update

>command in the code to get the cross references to update.

>You could also just use a second bookmark (the names have
be unique though)
>and use code such as the above to insert the data from
the form directly
>into the second bookmark.

>Another alternative is to have the command button create
DocumentVariables
>containing the data from the controls on the form and in
the template have
>{ DOCVARIABLE } fields where you want the data to appear.

>Please respond to the newsgroups for the benefit of
others who may be
>interested.

>Hope this helps
>Doug Robbins - Word MVP


>> Hi,

>> I'm looking to create a document template that opens a
>> user form when a new document is created (got this far
at
>> least). From there I want to be able to fill in some
text
>> boxes, click and button and hey presto all the
information
>> i filled in is transferred to the document in the
relevant
>> places ready for printing, like an on the fly mail
merge.

>> Unfortunately I can't figure out how to get this to
work.
>> I've been playing around with creating bookmarks and
then
>> setting  fields to reference them but this creates the
>> bookmarks in random places and I wouild prefer to either
>> have them hidden or not use then at all if there is
>> another way.

>> Any help would be greatly appreciated.

>> Thanks

>> Martin

>.



Mon, 05 Dec 2005 22:16:47 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. auto insert text on Enter key

2. Macro to auto-insert text while typing?

3. Auto popluate text box with data from another text box

4. Auto select text in a text box

5. auto highlight text in text boxes

6. retrieve an auto number after an insert

7. Inserting an auto signature into an email message

8. Auto Insert Image

9. Macro Request : auto insert pictures in a doc.

10. Auto Insert Picture

11. Auto insert pagebreak

12. Auto Insert Pictures

 

 
Powered by phpBB® Forum Software