Why word files with some VBA code get bigger and bigger over time?

H

Harvey

I have a macrobbok with over 50 procedures somewhere in our network and users
use it to create standard documents. when they create a document using the
macrobook they save it somewhere in the network and next time they need the
document they just modify some minor data or charts or add or remove some
text (using VBA code) and save it as a different version number. I noticed
after while the file gets so big does anyone know why is the reason ? Just as
an example I was checking a document today that was version 26 with 76 pages
it was 13MB I used the macrobook to create a new book based on that book
(macrobok has a procedure to trasfer all data from a book to a new book) and
I end up with only 1MB document which is identical to the version 26!
thanks :)
 
J

Jonathan West

Harvey said:
I have a macrobbok with over 50 procedures somewhere in our network and
users
use it to create standard documents. when they create a document using the
macrobook they save it somewhere in the network and next time they need
the
document they just modify some minor data or charts or add or remove some
text (using VBA code) and save it as a different version number. I noticed
after while the file gets so big does anyone know why is the reason ? Just
as
an example I was checking a document today that was version 26 with 76
pages
it was 13MB I used the macrobook to create a new book based on that book
(macrobok has a procedure to trasfer all data from a book to a new book)
and
I end up with only 1MB document which is identical to the version 26!
thanks :)

Combatting Template Bloat
http://www.word.mvps.org/FAQs/MacrosVBA/TemplateBloat.htm

Mind you, a bloat of that size is unlikely all to be down to bloat in the
VBA project. I suspect that there is some other cause as well - e.g. saving
multiple versions in the file, Track Changes being on, or something like
that.
 
H

Harvey

Thanks Jonathan for quick response
As you said this is not from bloat in the VBA code . also track changes is
not on and I checked it again and each version of the document has its own
file. Do you have any other ideas ?
Thanks :)
 
H

Harvey

Hi Jonathan
I thought to add something.
this is the case now :
1)I have two identical documents (76 pages) one is 1 mb another one is 13mb !
2)Both used a template as thier attachment to access over 50 macros .
3)track changes were off in both all the time.
4) the large file ( 13mb) was in production for over a year and each time
users opend it added or removed something to it and saved as a new version.
5) I copied all data on the large document and transfered to a new document
and got a smaller file(1mb)
6 character count in both documents are the same +48,000.
Thanks:)
 
J

Jean-Guy Marcil

Harvey was telling us:
Harvey nous racontait que :
Hi Jonathan
I thought to add something.
this is the case now :
1)I have two identical documents (76 pages) one is 1 mb another one
is 13mb ! 2)Both used a template as thier attachment to access over
50 macros . 3)track changes were off in both all the time.
4) the large file ( 13mb) was in production for over a year and each
time users opend it added or removed something to it and saved as a
new version. 5) I copied all data on the large document and
transfered to a new document and got a smaller file(1mb)
6 character count in both documents are the same +48,000.
Thanks:)

Do the macro have anything to do with customizing toolbars/and or their
menus?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

Harvey

Hi Jean
Yes there are some macros that add new toolbars and remove most of toolbars
and a lot of customization and protection for toolbars.
Thanks :)
 
J

Jean-Guy Marcil

Harvey was telling us:
Harvey nous racontait que :
Hi Jean
Yes there are some macros that add new toolbars and remove most of
toolbars and a lot of customization and protection for toolbars.
Thanks :)

Then this is probably the cause.
When you modify toolbars in a template (and save the results), the template
bloats. At least, this has been my experience.

Whenever I have to code something like this, I make sure that the changes
(to the toolbar) are not saved to the template.

This needs more coding because I have to rebuild the toolbar every time a
document is open. But it can be done.

I did something like this for a template that could create four distinct
types of document, each with its own toolbar set of menus.
I had to cater or the fact that a user cold have all four type of documents
opened at the same time, and thus navigate from one document to the other.
The toolbar had to dynamically change according to the document being
displayed in the active window...

I use document variables and document properties to keep track of the info I
needed and used those flags to rebuild the toolbar on the fly. This meant
that my code was full of
ThisDocument.Saved = True
statements to avoid having the user being bother with a prompt every time
they closed the last document based on the template. (If they said yes when
asked if they wanted to save the template, it would have bloated.)

There may be a way around that, but I have not figured it out yet. I must
admit that I have not looked into it too much either because in all cases it
was never practical for me to save the changes to the toolbars anyway, so
the "ThisDocument.Saved = True" approach has worked fine. The only problem
with this approach is that the user cannot create AutoText entries (or
otherwise save changes to the template) and save them to the template or
they will save the toolbar changes along the way. But this has never been an
issue with the projects I have been involved with.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

Harvey

Hi Jean Thanks for quick response
Those macros I mentioned are working in the background ( as soon as the
user opens a document which has that template as attachment It automatically
removes all toolbars except of 2 toolbars and also disables or removes a lot
of commands from menu bars and toolbars . So the user don't have any option
to make even minor changes to the toolbars . Having said this I don't think
we save anything into the template in terms of changes in the toolbars but
thanks for your views it gives me a clue to work on the problem but it seems
this bloating problem is more serious than it looks especially for large
documents and heavily coded templates.
Thank you 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