Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement,microsoft.public.word.vba.general,microsoft.public.word.vba.userforms,microsoft.public.word.vba.beginners
TomorrowsMan
 
Posts: n/a
Default Clearing Form Fields on 1st Doc Open only?

This seems it should be simple, but I'm spacing on it....

Hwo can I call the same macro from several Command Buttons without
having to copy the script to each Click() event?

So, I have a macro:

Sub ShowHello()
UserForm1.Show
End Sub

And let's just say I have three Command Buttons from which I would like
to launch the userform. Right now I would have:

CommandButton1_Click()
UserForm1.Show

CommandButton2_Click()
UserForm1.Show

CommandButton3_Click()
UserForm1.Show

So I end up having the script in 4 places; I know this is terribly
sloppy, but for some reason I'm just not conceiving of how to call the
other sub() macros from the buttons.....

Thanks!

Chris

  #2   Report Post  
Posted to microsoft.public.word.docmanagement,microsoft.public.word.vba.general,microsoft.public.word.vba.userforms,microsoft.public.word.vba.beginners
TomorrowsMan
 
Posts: n/a
Default Clearing Form Fields on 1st Doc Open only?

Ugh, sorry - I had a different question and found an answer, but forgot
to change the Subject line.....

  #3   Report Post  
Posted to microsoft.public.word.docmanagement,microsoft.public.word.vba.general,microsoft.public.word.vba.userforms,microsoft.public.word.vba.beginners
Jean-Guy Marcil
 
Posts: n/a
Default Clearing Form Fields on 1st Doc Open only?

TomorrowsMan was telling us:
TomorrowsMan nous racontait que :

This seems it should be simple, but I'm spacing on it....

Hwo can I call the same macro from several Command Buttons without
having to copy the script to each Click() event?

So, I have a macro:

Sub ShowHello()
UserForm1.Show
End Sub

And let's just say I have three Command Buttons from which I would
like to launch the userform. Right now I would have:

CommandButton1_Click()
UserForm1.Show

CommandButton2_Click()
UserForm1.Show

CommandButton3_Click()
UserForm1.Show

So I end up having the script in 4 places; I know this is terribly
sloppy, but for some reason I'm just not conceiving of how to call the
other sub() macros from the buttons.....

Thanks!

Chris


Try:
CommandButton1_Click()
DoCodeSub
End Sub

CommandButton2_Click()
DoCodeSub
End Sub

CommandButton3_Click()
DoCodeSub
End Sub

Sub DoCodeSub()
Dim MyForm as UserForm1
Set MyForm = New UserForm1
MyForm.Show
'Do other stuff
Set MyForm = Nothing
End Sub

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form fields versus mail merge fields [email protected] Microsoft Word Help 2 February 16th 06 02:12 PM
Why does text move around when typing in created form fields? jmbubble Microsoft Word Help 1 August 18th 05 12:01 AM
Replace mergefields with form fields jassi_Hayre Mailmerge 1 August 16th 05 10:49 PM
Having multiple form fields automatically updated jrwaguespack Microsoft Word Help 3 March 25th 05 07:43 AM
Form fields in frames - can I format the text (ie bold, italic)? La La Lara Microsoft Word Help 3 January 28th 05 03:09 PM


All times are GMT +1. The time now is 02:01 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"