Take me to the "next" subroutine

B

Blue Sky

Greetings MVP Word Gurus,

This should be an easy one for ya'. Like everyone else I have been giving a
work assignment to create an electronic automated Word form. I have read
Dian Chapman's wonderful article about creating Word forms (all four parts)
and have played around with the macros to better understand how they work.
My basic question is this. How do you program a subroutine to fill in a
field and then go to the next subroutine which will also fill in another
field? For example, taken from Dian's "Fill out form" article there is a
created form that uses text fields for a user's name, department, phone #,
etc. I understand how to create the macro for each field but can not get the
first subroutine to "go" to the next subroutine. All the fields are in
sequence. Any direction would be greatly appreciated.

thanks,

Blue Sky
 
B

Birgit

Hi!
Just put the names of the macro's under each other in order to call them.
Just as you call the first macro. All of them will be worked through, one
after the other.

Birgit.
 
B

Blue Sky

Birgit,

Thanks for the response. In Word, when I go to Tools, Macros I do see the
list of macros I have coded with VB Editor but I can not seem to change the
order in which they are listed. Any ideas?


thanks again,

Blue Sky
 
J

Jay Freedman

Hi Blue,

It has nothing to do with the order in which the macros are listed in the
Project Explorer pane (the left side of the VB editor). The important part
is in the code itself...

Referring to Dian's articles, particularly Part 3, she has you create an
AutoNew procedure that starts the processing. The AutoNew macro "calls" the
first field macro by having its name mUserName as a line of code:

If vAnswer = 6 Then
mUserName
Else
...

Now you want to "call" the mYesNo macro, and then maybe some more macros,
one for each field. You do that the same way, by putting the name of the
called macro in a line of code. You could have AutoNew call them all:

If vAnswer = 6 Then
mUserName
mYesNo
mAnotherField
mAnotherFieldAfterThat
Else
...

or you can go in just before the end of each macro and put the call to the
next macro there:

Sub mUserName()
vUserName = InputBox(Prompt:= _
"Pls enter your name and click ok.")
ActiveDocument.FormFields("bkUserName").Result _
= vUserName
mYesNo
End Sub

Sub mYesNo()
If vYesNoAnswer = 6 Then
ActiveDocument.FormField("ckYes").Checkbox.Value _
= True
Else
ActiveDocument.FormField("ckNo").Checkbox.Value _
= True
End If
mAnotherField
EndSub

.... etc.

My preference would be for the first method. One reason is that it makes it
easier to rearrange the order of the calls if you want to do that.
 

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