Memory error filling a MS Word document from MS Access

S

Sander

Hi,

I've got a problem with memory using MS Word..

Situation:
MS Office 2000 (fully updated)
Window w2k professional (fully updated)

I have a table on a SQL Server database.
In this table I put complete word documents as objects.

Now, I have a small vb script that copies the word object
and then pastes it in Word.
This works nice, but after a number of items, I get a
message: Not enough memory, If continuing you cannot
undo...
You can continue for a number of items, but after that
Word crashes..

I found a possible fix in the knowledge base concerning
too much edits, but this wasn't it.. I added a save
command, but I still got the problem...

Did anyone else have this problem???
Or maybe a solution??

Bye,
Sander
 
M

Malcolm Smith

Sander

This is a known problem in Word (and I am glad that I am not asked to
reproduce it) however, I do have a fix:


Private Sub PreventWordDeath(objWord As Word.Application, objDoc As
Word.Document)

On Error Resume Next


objDoc.UndoClear
objDoc.Repaginate

objWord.Options.Pagination = False
With objWord.Application
.ScreenUpdating = True
.ScreenRefresh
.ScreenUpdating = False
End With

End Sub


What you do is to call this routine with a pointer to Word and one to the
Document and call it after each longish iteration. I use this after each
table when I make my reports.

Here's an example of something which I use daily:
http://www.ukhorseracing.co.uk/selections/index.pdf

Just to prove that this fault is fixable.

Hope that this helps
- Malc
www.dragondrop.com
 
J

JGM

Hi Malcom,

I really do not mean to pick on details, but looking at your code a question
came to mind:
With objWord.Application
.ScreenUpdating = True
.ScreenRefresh
.ScreenUpdating = False
End With

Does this means that when using this Sub, we have to inlcude a

Application.ScreenUpdating = True

line near the end of the module calling the PreventWordDeath sub?
Or does ScreenUpdating always revert to True by default when the code
finishes executing?

Thanks for helping me learn!
Cheers!

p.s. Still got a bloody finger?
p.p.s You have wolves in Wales? Weren't they all hunted down long ago? If
not, you have to admire their resilience (something to think about while
trying to sleep...)!
;-)
 
M

Malcolm Smith

Ah, I think you're right.

In long report printouts it's usually best to turn off the ScreenUpdating
thing. It's been so long since I looked inside the routine that I forgot
to check.

One of those routines which sits in a module of its own and is reused
everywhere when I can.

Anyway, it does work and it does live up to its name. And, if you
followed the link, you can see what it does. From time to time I have
done reports up to 100 pages in length and it doesn't explode.

Yes, still in Wales though I am having two interviews in London next week.
One is a permie job and the other is a contract. Not sure what I am
going to do as I love it here but it will certainly mean that I will have
to get a suit as well as my hair cut as it hasn't seen a hairdresser in
over a year.

- Regards
Malc. www.dragondrop.com
 
S

Sander

Hi Malcolm,

This was the solution for me!!!!
Thanks.. This saves me a few days.... :)))

After adding your code it worked perfect...

Bye,
Sander
 
J

JGM

Hi Cindy,

Are you telling me that 2 softwares that are part of a single package, that
are designed to work together, that are closely inter-related, etc. etc. are
released by a large company in such a way that the said softwares have
behaviours that are different on such a simple issue?

Unbelievable!

Thanks for the heads-up!
 
C

Cindy M -WordMVP-

Hi Jgm,
Are you telling me that 2 softwares that are part of a single package, that
are designed to work together, that are closely inter-related, etc. etc. are
released by a large company in such a way that the said softwares have
behaviours that are different on such a simple issue?

Unbelievable!
Well... they started out as completely separate packages, back in the late
eighties. Their own development teams, totally different philosophies (one is
a spreadsheet and the other a word processor, after all)...

Only in 1993 or so did Microsoft's *marketing* come up with the "Office suite"
concept as a way to sell the entire spectrum of what a typical desktop should
need. And the purpose was to edge out the excellent stand-alone apps such as
Lotus 1-2-3 and WordPerfect (from two different companies). No thought was
given, at the time, to any kind of "standard" functionality or developer
interface.

Compared to what we had then, and what we have now, things have decidedly
improved (all the Office apps use VBA instead of a recorded macro, each with
its own language). But there are definitely things that Excel can do better
than Word, and vice versa. And also differing concepts for the same "term"
that can drive you practically nuts. This is one, how the two applications use
templates another.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

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

JGM

Hi Cindy,

Thanks for taking the time to explain things...

Now, M$ does not seem as totally incompetent as I previously thought, just
lazy!

And I know what you mean about templates... The first time I tried building
a toolbar in Excel, and to associate it with an .xlt, the way we do it with
a .dot... what a mess! I could not get rid of the ?&%$&/"$?$ toolbar... it
was always there! I took me a while to figure that one out!

Cheers!
 
C

Cindy M -WordMVP-

Hi Jgm,
Now, M$ does not seem as totally incompetent as I previously thought, just
lazy!
I'm not sure it's even that so much as $$$. Unlike the OpenOffice stuff,
there aren't a lot of officianados out there, distributing code out of the
goodnes off their hearts :) I suppose we could argue if MS would lay open
the code, this would also happen for their products. OTOH, seems, these
days, that the ones distributing code for free that interacts with MS
products are more the other kind (viruses) <sigh> So I suspect that, even if
MS were to consider opening up their source code, there might be lots of
liability questions involved.

If MS had to re-design and re-code such extensive applications from scratch,
it wouldn't be cheap! The question would then become: could the sales
possibly ever cover these costs?

So, a little bit at a time, for the most obvious things (Open, Save, New
file interfaces, for example) is probably the best we can hope for :)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

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

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