Insert text from UserForm into current cursor position

C

Charles Warner

I've done my Usenet homework on this, but still can't find the proper
syntax for this:

I have a UserForm open, with some text stored in the "txtInsert" field
in the form.

What is the syntax to attach to a command button on the form to insert
the value of txtInsert into the document at the current cursor
position?


TIA
 
P

Perry

Use the below in click event of yr commandbutton

Selection.Range = Me.txtInsert
Unload me

Krgrds,
Perry
 
J

Jay Freedman

Charles Warner said:
I've done my Usenet homework on this, but still can't find the proper
syntax for this:

I have a UserForm open, with some text stored in the "txtInsert" field
in the form.

What is the syntax to attach to a command button on the form to insert
the value of txtInsert into the document at the current cursor
position?

Selection.Text = txtInsert.Text

That statement will leave the entire insert highlighted. If you want
the cursor to move to the end of the insert, so that more stuff can be
inserted without overwriting, follow up with the statement

Selection.Collapse wdCollapseEnd
 
C

Charles Warner

Thank you both ... simple enough when you see it.

I've almost got this project together ... many thanks to those in this
group who pointed the way at each turn ...

I made the mistake of buying a book on Word a few months ago, not
realizing until I went to use it *seriously* that it was a poor
choice.

Could you recommend one that you consider the best? (I'm an 'ol MS
Access programmer ... know a bit about that, but making the transition
into Word's Object Model has been confusing - mostly *me* I guess, but
the book hasn't been much of a help.)

Best,

Charles
 

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