View Single Post
  #20   Report Post  
Posted to microsoft.public.word.docmanagement
MrsMac
 
Posts: n/a
Default Understanding Macros

Hi Dwoods,
I am very happy for you! Perhaps you see something that I have done wrong? I
would appreciate hearing from anyone out there who can pinpoint where I went
wrong in my steps. Thank you!

"Dwoods" wrote:

I have been following all of your responses on the enabling spell check in a
template as I have been trying to do the same thing. I want you to know I
followed all of your responses and my spell check is working in my template.
Thank you both!
--
Dwoods


"Shauna Kelly" wrote:

Hi MrsMac

I'm really glad to hear that your code is now working.

I'm assuming you put the VBA macro code into your forms template. And since
this is a form, I'm assuming that you're going to be sending it to other
people to use.

There are several ways to go about invoking your new macro. Here is one
relatively simple way.

Do File Open and open the template. Unprotect it. Do Tools Customize. On
the Toolbars tab, click New. Choose an appropriate name for the toolbar
(something that refers to the name of the form would be good). And tell the
little dialog box to save this new toolbar in your template (not
Normal.dot!).

Now, still in the Customize dialog, on the Commands tab, in the Categories
list, find Macros. In the right, in the Commands list, you'll see your macro
listed. Specifically, you're looking for RunSpellcheck. Drag that name to
your new toolbar. That will put a button on the toolbar that will invoke
your macro.

By default, the text on the button will be the name of the macro. If you
don't like that, right-click your new button (while the Customize dialog is
still open), and change the name. Play around with all the other options on
that right-click menu while you're there. If you make a complete mess, you
can just drag the button off the toolbar into mid-air to delete it, and then
start again.

If you decide you want an icon on your button, you can choose one from that
right click menu by using "Change button image". But the images there aren't
anything to write home about. Or you could use Edit Button Image, and create
your own. Or, you could pinch the existing spelling icon and copy that to
your new button if you like. The Customize dialog is still open, right? So
click Tools, then right-click Spelling and Grammar, copy that image. Back on
your own new button, right-click and choose Paste Button Image.

In any case, when you're finished, close the Customize dialog and save your
template.

The toolbar will be saved with the template, so if you distribute it to
others, it will go with the template.

Try it out by creating a new document, entering some text in, say, a form
field, and then clicking your new buttton.

There's more info, and screen shots showing some of the steps above at
http://word.mvps.org/FAQs/Customizat...oToToolbar.htm

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"MrsMac" wrote in message
...
Hi Shauna,
I'm sorry it has taken me several days to get back to this -- abscessed
tooth -- ouch! Thank you so much for helping me with this -- I am so lost.
Okay, I deleted the "Option Explicit" line, ran again. Came back with
another
error saying I had to add "End Sub" right before "Sub RunSpellcheck( )".
So I
typed this in and no more errors. Yaay! Little victories! I then locked
the
template and closed it down.

So I have the macro in there. I tried creating a new document and typing
errors in it, and I can't spellcheck it. I'm guessing this is where I have
to
put the button on the toolbar or something to run it? On the template or
the
new document? I'm sorry, I really need step-by-step help here because I
don't
understand what I'm doing. I so appreciate your assistance!


"Shauna Kelly" wrote:

Hi MrsMac

OK, for the moment, just delete the line that says "Option Explicit".
Then
try again.

As a bit of background, the Option Explicit line is not absolutely
essential
to running the macro. But it is good practice to use it when writing a
macro, because it forces the developer to explicitly declare all
variables.
If that doesn't make much sense to you now, that's OK, but one day it
will!

Specifically, there should be one Option Explicit line in the whole
module
(ie the whole kind of 'page' of macros), and it must be the very first
line
in that module.

But the macro will run without it, so for your purposes today, I'd
suggest
deleting it.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"MrsMac" wrote in message
...
Hi Shauna,
Thanks for your reply. I did as you suggested, and did find red dashes,
which I deleted. Ran it again, got the same error, and it tells me that
the
"Option Explicit" statement appears in a procedure and must be placed
at
the
module level. The farther I go, the loster I get!

I have many other questions regarding this whole issue, but I will take
it
one step at a time! Thank you again for your assistance.


"Shauna Kelly" wrote:

Hi MrsMac

I know how frustrating this can be! But from your description, it
looks
like
you've done everything correctly.

Let's check two things.

First, do Tools, Macro, Macros and click Run. You'll get the same
error
you
got before. The (Code) window will open again. Now, look through the
code.
Are there any lines in red? If so, they're a problem.

If you copied the text straight from the page at
http://word.mvps.org/FAQs/MacrosVBA/...ProtectDoc.htm, then you
will
have copied several horizontal lines on that page. They marked the end
of
one procedure and the beginning of the next. But they're just
window-dressing for the web page. So you may have several lines that
look
like -------------- in red. If so, delete those lines.

Does it work OK now?

If not, have a look through the code. You'll see that some is in green
(they're comments). And some is in black (that's the code that runs).
Is
there any text in red? If so, it's an error of some kind. If so, post
back
and copy the red bits into your message, so we can see what's going
wrong.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"MrsMac" wrote in message
...
Thank you both for your suggestions. I do appreciate it. After
spending
three
hours going over the documents, I'm as confused as ever. At this
point,
I
don't have time to understand macros anymore. I just have to be able
to
spellcheck this protected template and the resulting documents. So I
decided
to just paste the code from the mvp document and figure our macros
later,
figuring how hard could that be, right?

I follow the steps, I paste everything from the words "Option
Explicit"
until I get to "End Sub" right above the word Notes, because I'm
assuming
I'm
supposed to put all of this information in. I save and close
everything
down.
I open the template, go to Tools, Macro, Macros, click Run. The
(Code)
window
opens again in Visual Basic and I get this window: Compile error:
Invalid
inside procedure. I click on Help and understand absolutely nothing
that
help
tells me.

I've had someone tell me to explore OpenOffice.org as another way of
trying
to get this template to be spellcheckable. Any help anyone could
give
would
be appreciated!

"MrsMac" wrote:

Word 2003. Every time I run into a Word glitch, I'm directed
towards
macros.
I've been to the mvp site over and over. I simply do not understand
macros at
all. I don't understand how to create one, how to run one, what all
that
"stuff" means, etc. I have tried numerous times and end up shutting
everything down in total frustration. I gladly do the repetitive
tasks
that
macros are supposed to streamline because it's easier than trying
to
figure
out macros!

But now I HAVE to figure them out -- I'm creating a large series of
locked
forms templates that will need to be spellchecked after data entry
and
I
can't find a workaround.

I want to do a continuing ed class on this, but in the interim can
anyone
recommend a book that offers REALLY simple, step-by-step
explanations
of
macros? I'm stressing REALLY SIMPLE here! I checked my local
library
for
"Macros for Dummies" but got no hits. I appreciate any direction
anyone
can
give. Thank you!