Group:  Microsoft Word ยป microsoft.public.word.vba.userforms
Thread: Set insertion point in Document from UserForm

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Set insertion point in Document from UserForm
"sabtve" <tvekvoll[ at ]hotmail.com> 28.02.2006 18:48:58
Hello.
I have created a Document template (a letter) in Word2003, using the eminent
guidance found in "How to create a Userform" (Many thanks, Doug. Really got
me started).
And it works beautifully, apart from the fact that after the data from the
UserForm are inserted into respective Bookmarked fields in the Document, the
insertion point is at the top of the Document, and not where I have
specified "Write your letter here...".
And being a novice, I have not been able to find how to place the cursor
automatically (progammed) in the right field (macro?). So I have to resort
to you. Probably trivial, but I give up.

Second q.: I have tried to write vb code behind the "zip" field (TextBox1)
on the form, to
validate keyed inn fields (max no. of digits, all numbers
aso)..
The code is ok and shows error MsgBox and all, but this
happens after the 1. digit in the field is keyed in.
I want it to check after the whole field is filled in.
Other fields (name, address) will be checked for blanks and
so on.
The reason is probably in the TextBox1.Changed event, but I
don't understand what to do.
Hva also tried to put the code behind the "Transfer to
letter" button instead, to test the fields in afterhand,
but that didn't work much good at all.
Best thing would be to test the fields as they are filled
in.
Any tips here? Pretty stuck now.

Sincerely
Tom V. Ekvoll
Oslo, Norway


Re: Set insertion point in Document from UserForm
"Charles Kenyon" <wordfaq[ at ]nospam.addbalance.com> 28.02.2006 19:04:47
You can use bookmarks to tell your userform where you want things, including
the insertion point when it is closed. On the other hand, I use styles
rather than bookmarks for many of my insertion points. I use one style for
the date line, a different style for the initial line of the inside address,
a third for the continuation lines, a different one for the reference line,
for the greeting, and for the body of the letter. I do this because these
styles are very handy when creating continuation headers/footers. You use a
StyleRef field to pick up these bits of information. You can have your
userform's closing procedure search for the first instance of the body text
style if you want. I have a macrobutton field with the display [Type letter
here.] and have my procedure select that field. Lots of options available.

Actually, I have my letter template set up with lots of macrobutton fields.
My Userform puts things in those fields (replacing the fields). If the user
cancels the UserForm, the macrobutton fields are there in the document as
prompts and can be reached easily with the F11 key.

See http://www.addbalance.com/usersguide/fields.htm#MacroButton and
http://www.mvps.org/word/FAQs/TblsFldsFms/UsingMacroButton.htm for more
about macrobutton fields.

Take a look at: How to set up letterhead or some other document where you
want one header on the first page and a different header on other pages.
http://www.addbalance.com/word/headersfooters.htm This gives step-by-step
instructions. (It also has the following links)

Some other pages to look at:

Letterhead Tips and Instructions
http://sbarnhill.mvps.org/WordFAQs/Letterhead.htm

Letterhead Textboxes and Styles tutorial
http://addbalance.com/word/download.htm#LetterheadTextboxesAndStylesTutorial

Template Basics
http://www.addbalance.com/usersguide/templates.htm

How to Create a Template - Part 2 - essential reading
http://www.mvps.org/word/FAQs/Customization/CreateATemplatePart2.htm

Word "Forms"
http://www.addbalance.com/word/wordwebresources.htm#Forms and

Word for Word Perfect Users
http://www.addbalance.com/word/wordperfect.htm if you are coming from a WP
environment (or even if you are not).

Hope this helps,
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


"sabtve" <tvekvoll[ at ]hotmail.com> wrote in message
news:%23ESSLhJPGHA.2268[ at ]TK2MSFTNGP09.phx.gbl...
[Quoted Text]
> Hello.
> I have created a Document template (a letter) in Word2003, using the
> eminent guidance found in "How to create a Userform" (Many thanks, Doug.
> Really got me started).
> And it works beautifully, apart from the fact that after the data from the
> UserForm are inserted into respective Bookmarked fields in the Document,
> the insertion point is at the top of the Document, and not where I have
> specified "Write your letter here...".
> And being a novice, I have not been able to find how to place the cursor
> automatically (progammed) in the right field (macro?). So I have to resort
> to you. Probably trivial, but I give up.
>
> Second q.: I have tried to write vb code behind the "zip" field (TextBox1)
> on the form, to
> validate keyed inn fields (max no. of digits, all numbers
> aso)..
> The code is ok and shows error MsgBox and all, but this
> happens after the 1. digit in the field is keyed
> in. I want it to check after the whole field is filled in.
> Other fields (name, address) will be checked for blanks and
> so on.
> The reason is probably in the TextBox1.Changed event, but I
> don't understand what to do.
> Hva also tried to put the code behind the "Transfer to
> letter" button instead, to test the fields in
> afterhand, but that didn't work much good at all.
> Best thing would be to test the fields as they are filled
> in.
> Any tips here? Pretty stuck now.
>
> Sincerely
> Tom V. Ekvoll
> Oslo, Norway
>


Re: Set insertion point in Document from UserForm
"sabtve" <tvekvoll[ at ]hotmail.com> 28.02.2006 19:19:36
Thank you for a very prompt answer.
Evidenltly, a lot of study is a head of me. But this is fun, even if
frustrating.

Thanks again
Tom

"Charles Kenyon" <wordfaq[ at ]nospam.addbalance.com> wrote in message
news:u0MKTnJPGHA.1032[ at ]TK2MSFTNGP11.phx.gbl...
[Quoted Text]
> You can use bookmarks to tell your userform where you want things,
> including the insertion point when it is closed. On the other hand, I use
> styles rather than bookmarks for many of my insertion points. I use one
> style for the date line, a different style for the initial line of the
> inside address, a third for the continuation lines, a different one for
> the reference line, for the greeting, and for the body of the letter. I do
> this because these styles are very handy when creating continuation
> headers/footers. You use a StyleRef field to pick up these bits of
> information. You can have your userform's closing procedure search for the
> first instance of the body text style if you want. I have a macrobutton
> field with the display [Type letter here.] and have my procedure select
> that field. Lots of options available.
>
> Actually, I have my letter template set up with lots of macrobutton
> fields. My Userform puts things in those fields (replacing the fields). If
> the user cancels the UserForm, the macrobutton fields are there in the
> document as prompts and can be reached easily with the F11 key.
>
> See http://www.addbalance.com/usersguide/fields.htm#MacroButton and
> http://www.mvps.org/word/FAQs/TblsFldsFms/UsingMacroButton.htm for more
> about macrobutton fields.
>
> Take a look at: How to set up letterhead or some other document where you
> want one header on the first page and a different header on other pages.
> http://www.addbalance.com/word/headersfooters.htm This gives step-by-step
> instructions. (It also has the following links)
>
> Some other pages to look at:
>
> Letterhead Tips and Instructions
> http://sbarnhill.mvps.org/WordFAQs/Letterhead.htm
>
> Letterhead Textboxes and Styles tutorial
> http://addbalance.com/word/download.htm#LetterheadTextboxesAndStylesTutorial
>
> Template Basics
> http://www.addbalance.com/usersguide/templates.htm
>
> How to Create a Template - Part 2 - essential reading
> http://www.mvps.org/word/FAQs/Customization/CreateATemplatePart2.htm
>
> Word "Forms"
> http://www.addbalance.com/word/wordwebresources.htm#Forms and
>
> Word for Word Perfect Users
> http://www.addbalance.com/word/wordperfect.htm if you are coming from a WP
> environment (or even if you are not).
>
> Hope this helps,
> --
>
> Charles Kenyon
>
> Word New User FAQ & Web Directory: http://addbalance.com/word
>
> Intermediate User's Guide to Microsoft Word (supplemented version of
> Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
>
> See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
> --------- --------- --------- --------- --------- ---------
> This message is posted to a newsgroup. Please post replies
> and questions to the newsgroup so that others can learn
> from my ignorance and your wisdom.
>
>
> "sabtve" <tvekvoll[ at ]hotmail.com> wrote in message
> news:%23ESSLhJPGHA.2268[ at ]TK2MSFTNGP09.phx.gbl...
>> Hello.
>> I have created a Document template (a letter) in Word2003, using the
>> eminent guidance found in "How to create a Userform" (Many thanks, Doug.
>> Really got me started).
>> And it works beautifully, apart from the fact that after the data from
>> the UserForm are inserted into respective Bookmarked fields in the
>> Document, the insertion point is at the top of the Document, and not
>> where I have specified "Write your letter here...".
>> And being a novice, I have not been able to find how to place the cursor
>> automatically (progammed) in the right field (macro?). So I have to
>> resort to you. Probably trivial, but I give up.
>>
>> Second q.: I have tried to write vb code behind the "zip" field
>> (TextBox1) on the form, to
>> validate keyed inn fields (max no. of digits, all numbers
>> aso)..
>> The code is ok and shows error MsgBox and all, but this
>> happens after the 1. digit in the field is keyed
>> in. I want it to check after the whole field is filled in.
>> Other fields (name, address) will be checked for blanks
>> and so on.
>> The reason is probably in the TextBox1.Changed event, but
>> I don't understand what to do.
>> Hva also tried to put the code behind the "Transfer to
>> letter" button instead, to test the fields in
>> afterhand, but that didn't work much good at all.
>> Best thing would be to test the fields as they are filled
>> in.
>> Any tips here? Pretty stuck now.
>>
>> Sincerely
>> Tom V. Ekvoll
>> Oslo, Norway
>>
>
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net