Automate a form by saving macros in the form template...?

G

Guest

Hi all,

MSOffice Online says "you can automate a form by saving macros in the form
template. The macros run automatically when the insertion point enters or
exits a form field. For example, if a user selects a MARRIED check box, an
exit macro can activate other related fields, such as NAME OF SPOUSE."

Okay, here's the prob...I've never used macros, and need to know how one
would create a macro like this one used in the example given. If I knew how
to do one like the one in this example (where the NAME OF SPOUSE appears only
after someone checks the MARRIED box), I could apply it to what I'm trying to
do.

Thanx in advance to anyone who can help--or even point me in the right
direction to where I could find the answer to this. I'm using Word 2003
version.
 
G

Guest

Natalie:

You can get started with macros by recording one of your own. Click Tools >
Macro > Record New Macro. In the Record Macro dialog box, enter a name for
your macro. Don't bother assigning it to a toolbar or keyboard shortcut. DO
pay attention to the Store Macro In box. That specifies where the macro is
going to be saved.

In your case, you could either save it in the document or in the template
you created the document from. If you didn't create the document from your
special form template, you should probably save it in your document while
you're still in "test" mode.

There's no time element in recording your macro. You can go through the
steps as slowly as you like. You can click the Pause Recording macro any time
to perform actions that won't get recorded. Just remember to click it again
to resume recording.

Do something simple, like typing some text then applying a style to the
text. Then stop the recording by clicking the Stop Recording button.

Now let's look at the macro you recorded in the Visual Basic Environment
(VBE). The most direct way to get there is to click Tools > Macro > Macros.
In the Macros dialog box, select your document (not the template) in the
Macros In list. There should only be one macro that shows up in the Macro
Name list -- the one you just recorded. Select that macro, then click Edit.
This opens the VBE with the code from your macro displayed.

You can edit the code however you like. But for now, let's just use that
code as the exit macro from one of your form fields.

For any form field in your form, open the field's options dialog box by
double-clicking the field, then select your macro from the Run Macro On Exit
list. Switch to protected mode by clicking the Protect Form button, tab into
then out of your field. Your macro should run.

That's the overview. Once you have your form template designed, you can
record or create your macros there and delete the ones from your document.

For a detailed workout on these matters, please see Dian Chapman's excellent
tutorials:

http://www.mousetrax.com/TechPage.html#autoforms

Bear
 

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