VBA Project Compilation - Is It Worth It?

S

Simon E

In Word 97 VBA (VBA 5) when I compile a large project the size of the template increases by 30%. I find compiling is useful for error checking but don't like adding 300KB to a 1MB file that has to be deployed to numerous offices around the world, sometimes across very slow dial-up links.

I have tried searching the Word MVP site, and Google and Google Groups, and MSDN. I cannot find an explanation of what compilation does to a VBA project or whether, when the project is executed, the compiled code is executed or whether the code is still executed by an interpreter, line-by-line

Apart from error checking and increasing the size of a file, what effect does compiling a VBA project (in Word, Excel, or elsewhere) have? When users come to run the macros in the compiled project, do they run the compiled code or is the code still run line-by-line by an interpreter? Does the VBA 6 used in Words 2000, 2002, 2003 behave the same as VBA 5 (we are upgrading to Word 2002/VBA 6 in a month's time)

Cheer
Simon Elm
 
H

Helmut Weber

Hi Simon,
don't know much, in fact, I know nothing about what compiling does
to a dot. If you want to decrease the size and you have XP and 97,
then this might help. I had got an 1 MB dot (97), opened it in XP,
saved it, and it was 300 KB afterwards.
Though, I have no clue, why this happened.
I could speculate a lot, but not in public.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 
E

Ed

Simon - From what I understand, any VBA from Word 97 will run under VBA 6.
I was just "upgraded" from 2000 to XP, and had no problems executing code
contained only on my machine. I have had MAJOR problems, though, publishing
files with macros to other users.

The problem is the library references VBA looks for. With early binding,
you set your objects and they want the XP object libraries - and your code
will not run on anything below XP. In Excel, you can use late binding, and
the VBA will find the library on the user's machine and set the object to
the user's version of the program. Word, however, will NOT! Word *insists*
on XP only!, even with late binding. So if you have to publish any code to
users with a "lower" program version, get ready for some fun!

Ed

Simon E said:
In Word 97 VBA (VBA 5) when I compile a large project the size of the
template increases by 30%. I find compiling is useful for error checking
but don't like adding 300KB to a 1MB file that has to be deployed to
numerous offices around the world, sometimes across very slow dial-up links.
I have tried searching the Word MVP site, and Google and Google Groups,
and MSDN. I cannot find an explanation of what compilation does to a VBA
project or whether, when the project is executed, the compiled code is
executed or whether the code is still executed by an interpreter,
line-by-line.
Apart from error checking and increasing the size of a file, what effect
does compiling a VBA project (in Word, Excel, or elsewhere) have? When
users come to run the macros in the compiled project, do they run the
compiled code or is the code still run line-by-line by an interpreter? Does
the VBA 6 used in Words 2000, 2002, 2003 behave the same as VBA 5 (we are
upgrading to Word 2002/VBA 6 in a month's time)?
 
H

Howard Kaikow

If you will need to use Word 2002 macros in Word 97, then you have 2
choices:

1. Use late binding, which is much slower in execution time and makes
writing the code harder.
2. Use early binding, in which case you must do the development in Word 97.

Anything else would be unreliable and unsupported.

--
http://www.standards.com/; See Howard Kaikow's web site.
Simon E said:
Thanks for the warning, Ed, I'll keep it in mind in case we find ourselves
using 2002 templates in 97. We're hoping that we can avoid that though
(fingers crossed!).
I did port some code across from 2002 to 97 a couple of months ago and had
plenty of fun with little things like the Split and Join functions and
enumerated values. I now have quite an aversion to reusing 2002 code in 97.
Luckily the 97 machines won't linger - once the rollout is complete they're
history (although admittedly the rollout will take up to six months).
 
E

Ed

Howard, I went all over the "late binding" issue - I think on this NG, the
Excel NG, and the VB NG. The problem came down to Word XP *refusing* to
look backwards, even with late binding, to find the Word9 library reference.
I even tried (though all know I am *NOT* the greatest VBA coder!) to copy
the Word9 DLL ont my maching, and programmatically change the reference from
Word10 to Word9 - but it refused to work. I'm now working on some external
VB solutions.

Ed
 
P

Peter Hewett

Hi Ed

What Howards saying is that If you install and develop against Word 97 it will work
correctly against any later version of Word - Even if your code is early bound.

Even using late binding against Word XP in your development environment is quite possibly
going to cause you problems if you want the code to Word with Word XP. The basic problem
is that Word XPs object model is a superset of what's available with Word 97.

It does *not* matter what the host application is Excel/VB the issue is the version of
Word you use. Develop against XP at your own risk.

The normal method is to early bind against the oldest version of Word/Ofiice you want to
support and then when you've finished coding and in the testing phase test against later
versions of Word/Office in case you encounter something Microsoft broke.

BTW the performance hit of running late bound code can be in 30/40% region if the articles
I've read are correct.

HTH + Cheers - Peter
 
S

Simon E

Howard & Pete

Thanks for your comments. Good explanation - 2002 is a superset of 97

Cheer
Simon
 

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