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

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!