Using a previous procedure event

J

Jason Logue

How do I call or dim an event from a previous procedure in
a userform? I am using userforms, and the user will click
on a button to open another window, and in that window
they will click another button, and finally, in the last
window they will click another button that initiates code
that goes out finds bookmarked text and plops it into a
textbox adjacent to the first button in the first
userform. I would like the code under the final
commanbutton to determine which original button was
clicked and insert the text appropriately. Here is what I
have so far:

Sub CommandButton1_Click()



Set source = Documents.Open("C:\Documents and
Settings\Logue\My Documents\Allied
Title\exceptions\exceptions.doc")

(this is where the bookmarked text is located)



If Userform3.ExceptionsButton1_Click Then

(my attempt to tell say if the button was clicked in
userform3, which is the starting place of this whole
event, then the following code will take place)


Userform3.TextBox8.Text = source.Bookmarks
("Chapter1_1").Range

End If

(and if it was clicked, then it moves on to this next bit
of code and so on)

If Userform3.ExceptionsButton3_Click Then

Userform3.TextBox4.Text = source.Bookmarks
("Chapter1_1").Range

End If

and it goes on...

Right now it's either doing nothing or inserting code in
every textbox on the original userform. Any suggestions
are welcome.

TIA,
Jason
 
W

Word Heretic

G'day "Jason Logue" <[email protected]>,

set variables of appropriate scope to the destination.


How do I call or dim an event from a previous procedure in
a userform? I am using userforms, and the user will click
on a button to open another window, and in that window
they will click another button, and finally, in the last
window they will click another button that initiates code
that goes out finds bookmarked text and plops it into a
textbox adjacent to the first button in the first
userform. I would like the code under the final
commanbutton to determine which original button was
clicked and insert the text appropriately. Here is what I
have so far:

Sub CommandButton1_Click()



Set source = Documents.Open("C:\Documents and
Settings\Logue\My Documents\Allied
Title\exceptions\exceptions.doc")

(this is where the bookmarked text is located)



If Userform3.ExceptionsButton1_Click Then

(my attempt to tell say if the button was clicked in
userform3, which is the starting place of this whole
event, then the following code will take place)


Userform3.TextBox8.Text = source.Bookmarks
("Chapter1_1").Range

End If

(and if it was clicked, then it moves on to this next bit
of code and so on)

If Userform3.ExceptionsButton3_Click Then

Userform3.TextBox4.Text = source.Bookmarks
("Chapter1_1").Range

End If

and it goes on...

Right now it's either doing nothing or inserting code in
every textbox on the original userform. Any suggestions
are welcome.

TIA,
Jason

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
J

Jason Logue

Okay, I understand that but how do I do it for this
situation and where? I am a newbie, so I am still
learning.


TIA,
Jason
 
W

Word Heretic

G'day "Jason Logue" <[email protected]>,

Public ButtonClick as Long


sub Command_Button1_Click

ButtonClick=1
'do other stuff
end sub

sub Command_Button2_Click

ButtonClick=2
'do other stuff
end sub

Okay, I understand that but how do I do it for this
situation and where? I am a newbie, so I am still
learning.


TIA,
Jason

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
J

Jason Logue

I hate to be a bother about this, but should the "Public
buttonclick as long, sub command_button1_click code" go on
the userform that contains the textboxes (the place where
the text is inserted), or should it go in the code under
the final button they click. Right now it still inserts
the bookmark in each textbox without using any of my If

I have the following code under one Commandbutton in the
final window (keep in mind, your code farther below is in
the original userform with the textboxes):

Set source = Documents.Open("C:\Documents and
Settings\Logue\My Documents\Allied
Title\exceptions\exceptions.doc")

If 1 Then

Userform3.TextBox8.Text = source.Bookmarks
("Chapter1_1").Range



End If

If 2 Then



Userform3.TextBox4.Text = source.Bookmarks
("Chapter1_1").Range

End If...and so on...

And as of now, it bumps right to the userform3.textbox
(whatevernumber).text = source...and so on, and inserts
the text in all the textboxes on that page
indiscriminately.

Thanks,
Jason
 
S

Steve Hudson

G'day "Jason Logue" <[email protected]>,

is this still outstanding? Sorry for the delay - silly season, moved
house & ISPs etc.

I hate to be a bother about this, but should the "Public
buttonclick as long, sub command_button1_click code" go on
the userform that contains the textboxes (the place where
the text is inserted), or should it go in the code under
the final button they click. Right now it still inserts
the bookmark in each textbox without using any of my If

I have the following code under one Commandbutton in the
final window (keep in mind, your code farther below is in
the original userform with the textboxes):

Set source = Documents.Open("C:\Documents and
Settings\Logue\My Documents\Allied
Title\exceptions\exceptions.doc")

If 1 Then

Userform3.TextBox8.Text = source.Bookmarks
("Chapter1_1").Range



End If

If 2 Then



Userform3.TextBox4.Text = source.Bookmarks
("Chapter1_1").Range

End If...and so on...

And as of now, it bumps right to the userform3.textbox
(whatevernumber).text = source...and so on, and inserts
the text in all the textboxes on that page
indiscriminately.

Thanks,
Jason

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

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