Change TextBox Focus

C

call_me_sol

HI -
I created a text box. The box accepts input from users. Upon hitting
the "paste" button, the text box replaces specific bookmarks within a
document. After hitting paste, the text box closes.

I need to change the behavior of the text box so that upon hitting the
"paste" button, the test box goes to the background and the document
comes to the foreground becoming active. This will allow users to copy/
paste the contents of the document to be used elsewhere. After users
have finished using the document, I need them to be able to return to
the text box (ideally, just clicking on it because it'll be in the
background) and starting the process over again (I added a "clear"
button to the text box already).

Is this possible?

Here is my current code:

Private Sub CommandButton1_Click()
Dim oRng As Word.Range
Dim oBMs As Bookmarks
Set oBMs = ActiveDocument.Bookmarks
Set oRng = oBMs("RD").Range
oRng.Text = TextBox1
oBMs.Add "RD", oRng
Set oRng = Nothing
Set oBMs = Nothing
Unload Me
End Sub

Private Sub CommandButton2_Click()
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
End Sub

Thank you for your help.
 
D

Doug Robbins - Word MVP

Just put a button on the toolbar to call the macro that you are using to
load the userform in the first place.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

call_me_sol

Hi

Thanks for the reply. I'd rather not do that. The text box is going
to be used quite frequently (several dozen times) so it will become
sort of cumbersome to keep hitting a button on the toolbar to start
the box each time.

Is there anyway to make the text box fade to the background while its
not in use? Then, when its clicked on again, make it come to the
foreground (essentially like toggling between two windows). It seems
that right now when the text box is open I can only work IN the text
box -- i can't toggle into the document.

Thanks for the reply again, Doug.
 
D

Doug Robbins - Word MVP

I can't see any difference between having to click on a toolbar button and
clicking anywhere else.

If it needs several dozen clicks, there's a good chance that the whole
approach is somewhat less than optimal.

Note that you seem to bave posted this to microsoft.public.word.vba, which
is not a valid newsgroup. You probably meant
microsoft.public.word.vba.general

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

call_me_sol

Fair enough :) I'm the novice here -- lol

OK, so one last question. I've added the button to the toolbar (which
looks like a "play" button). When I do that, though, it prompts me to
choose a macro to run. Is there any way to make the "play" button
simply start my macro -- the only macro in the template?


Thanks for all of the help, Doug.
 

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

Similar Threads

User Form Problems 4
User Form Issues 2
Clear button for text box 1
Clear Button 5
Bookmark question 4
Extract name, address and ph# 8
Capturing a Content Control Range 0
Dynamic Naming of Form Button 3

Top