Macro efficiency vs other languages?

J

Jason

Ok, hopefully this is an ok place to ask this but I couldn't find anywhere
else that seemed appropriate. I'm inheriting a word macro that basically
takes huge HUGE documents and parses them. Roughly what it does is split the
document at certain keywords into seperate individual documents. I'm told
that currently the process if very very slow. I'm simply wondering, due to
having no real experience with macros, if this process would be quicker in
another language, like Perl or something? I just don't know how efficient
macros are and if they are as efficient, less efficient, or more efficient
than other programming languages. Anyone able to offer their thoughts? It
would be much appreciated, thank you.
 
D

Doug Robbins - Word MVP

Whatever the language, it could depend very much on how the operation is
being performed - particularly the method of locating the keywords.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

macropod

Hi Jason,

With any form of coding, its possible to write such that it executes efficiently or inefficiently. Some languages may execute more
efficiently than others, but you also have to recognise that, if you're automating another application (in this case Word), whatever
language you use is going to have to work within that application's limitations.

A common mistake with all Office applications is to use Selections where Ranges can be used. Selecting objects is much less
efficient than simply specifying their ranges. Unnecessary screen updating and allowing Word tables to automatically resize as text
in them is changed also add significant overheads.
 
S

StevenM

To: Jason,

I would suspect that the speed that your computer can read and write
information to your hard drive, as well as the amount of RAM available on
your system, will have more to do with how fast your code executes than what
computer language the code was written in. No doubt other programming
languages can do many things better than VBA, but I seriously doubt working
with Word documents is one of them. Do you really want to speed up your
project? Work with text files instead of Word documents, making this change
should speed things up significantly. But if it is absolutely necessary for
you to work on Word documents, things will go much quicker if you worked on
petite documents rather than “HUGE†documents. After all, I suspect that
while working with “HUGE†documents you’re running out of RAM and Word is
forced to create “virtual memory†(which entails reading and writing parts of
your document into temporary files on the hard drive). This has the
unfortunate consequence of taking an already slow macro and making it much
slower. I call it hitting “molasses mode†— a macro which should run in ten
or fifteen minutes, takes an hour or more to complete. If that is your
problem, I seriously doubt that switching computer languages is going to help
you any. They won’t be able to create RAM out of thin air, they will be
forced to do the same thing as VBA does, create “virtual memory,†and that
will be much slower than real RAM. But even with added RAM, the problem with
your project is that it does a lot of reading and writing to the hard disk,
and the time that that takes has little to do with whatever computer language
is used.

Steven Craig Miller
 
C

Cindy M.

Hi Jason,
I'm told
that currently the process if very very slow. I'm simply wondering, due to
having no real experience with macros, if this process would be quicker in
another language, like Perl or something?
This depends very much on which file format the documents are saved in. If
it's a newer XML file format then you can probably process them much faster
by not using macros, but working with the closed files using standard XML
tools of any high-level programming language (such as the .NET Framework).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

Jason

Thank you all very much. I think You've given me some great suggestions and
insight. I believe its accurate that its probably the computer and lack of
RAM slowing things down, not to mention the hard drive access. I will look
into accessing the file through the XML format and see if that is a viable
and perhaps quicker solution. Thank you all again.
 

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