Macro length limitations in Word 2004

G

Gene

We have some Word 2003 for Windows macros that we are trying to run in Mac
Word 2004. (We are opening our Word 2003 files in Word 2004 and then running
the macros in them.) We are getting "procedure too long" error messages. If
we divide the macros into 2 macros and run them one at a time they run fine
in Mac Word 2004. This means, however, that what takes one operation in
Windows takes 2 operations on the Mac.

Is there anything to do to get around this?

Thanks,
Gene
 
J

JE McGimpsey

Gene said:
We have some Word 2003 for Windows macros that we are trying to run in Mac
Word 2004. (We are opening our Word 2003 files in Word 2004 and then running
the macros in them.) We are getting "procedure too long" error messages. If
we divide the macros into 2 macros and run them one at a time they run fine
in Mac Word 2004. This means, however, that what takes one operation in
Windows takes 2 operations on the Mac.

Is there anything to do to get around this?

How many lines of code are in your procedure?

I would first try Rob Bovey's Code Cleaner in XL03:

http://www.appspro.com


Next I would seriously look at your code to see if your coding is
efficient.

Third, there should be no problem breaking up the macro into 2
procedures, then calling the second one at the end of the first. It will
probably cause your code to take a few milliseconds longer. Just make
sure you pass relevant variables to the second procedure (or make them
global).
 
G

Gene

Dear JE,

Thanks very much for the suggestions. I will pass them to my colleague who
is doing this project. If he learns something useful I will report back.

Best regards,
Gene
 
K

Klaus Linke

Next I would seriously look at your code to see if your
coding is efficient.


I've run into that problem in Word2003, too. Some of my macros are just
very, very long "Select Case" statements, with possibly hundreds of cases.

Splitting them up really isn't an option. I just had to spend an hour
yesterday to re-write "Case a : Case b : ... Case e" as "Case a to e"
whereever possible, to get around that stupid limitation (which probably is
4k characters/procedure).

Regards,
Klaus
 
G

Gene

Well, we split the macros into 2 parts and called the second with the first.
It works fine; thank you.

What we really are curious about is knowing why Mac Word 2004 is more
limited than Windows Word 2003. Anybody know?

Thanks,
Gene
 
J

JE McGimpsey

Gene said:
Well, we split the macros into 2 parts and called the second with the first.
It works fine; thank you.

What we really are curious about is knowing why Mac Word 2004 is more
limited than Windows Word 2003. Anybody know?

Assuming that the length was actually the problem (and if it's working
now, it likely was), the reason is probably related to MacWord (all
versions) using VBA5 and WinWord2003 using VBA6.3.

While VBA6 didn't add a *lot* of new functionality, there were a lot of
changes under the hood. I've never run into a length limit (I tend to
write very modularized code), but it wouldn't surprise me if the
compiler was updated to work with longer code.
 
G

Gene

I did not know enough to know how to ask the question, but you just answered
it. Thanks. I did not know about the different versions of VBA. That
undoubtedly is the reason.

Thanks again,
Gene
 

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