Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where does Word use up memory?

Status
Not open for further replies.

ycim

Programmer
Feb 9, 2005
95
0
0
CA
I have an Access program whereby I am importing some information into access from Word documents. The code also looks for certain criteria in the Word documents, and breaks it up into smaller word documents based upon those criteria. A typical word file that I am trying to break down into smaller units could contain as many as 500 different pieces, but each of those pieces is less than a page long (usually).

The code is very intense and quite lengthy so I won't post it all here, but basically, the flow is as follows..

1. Create an object (Set WD = createObject("Word.Application")
2. Open the original word document
3. Find my content in the document
4. Set a range for that content
5. Copy the range
6. Create a new document (and yes, another instance of Word running)
7. Paste in the content
8. Close the new document
9. Return to my original document and find the next piece, and then repeat steps 3-9.

I know that the code that I have is not opening tons of word applications. At most, I only have 2 sessions running.

The program successfully breaks down the documents and it copies about the first 20 documents, and then I get an "out of memory" problem, and I obviously can't get it to go further.


I am not asking anyone to write the code, but rather I am asking for advice on where to start looking for memory leaks? Although I am a power user in both Access and Word, this is my first program that I have accessed Word through VBA (I have done tons of Access VBA programming, though!)

Can anyone suggest where to start my hunt? I am afraid that I simply don't know where to look.

Thanks for your help.
 
1. Tony, I believe CBA's situation (dual monitors, extremely messed up documents, use of dialogs with one document) is the exception that proves the rule. It seems quite reasonable to me, under those circumstances. The "rule" still stands though, one instance is all that is needed for most actions with Word.

2. CBA - incorrect. Hugh's code does not preserve format.

Gerry
My paintings and sculpture
 
I stand corrected Gerry. I knew the code I provided didn't since the temporary variable is just a string variable. While on the other hand the range object contains the formatting. It just doesn't make it into the new document.

P.S. Nice art work.
 
CBA - Yes, you are correct. Word Dialogs are limited to one per instance. If you want multiple concurrent ones you need multiple instances - but that wasn't what you said before :)

Gerry - I do know there are some very odd and non-intuitive effects caused by the use of multiple monitors but I don't think they have any significant bearing in this case. The requirement to use multiple dialogs, though, as just said, does need multiple instances.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
Tony, the bearing of the the multiple monitors is that he can SEE both instances fully, at the same time. Which, if I understand correctly, is actually the point.

Gerry
My paintings and sculpture
 
Yes, but he could do that with a single instance. I do accept the dialogs aspect if that's what's wanted but not the view aspect. For a single user working with the UI it doesn't really make much difference although, if code were involved (which I would almost certainly want), then a single instance would probably be easier.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
Oh....OK, are you saying (the dialog issue aside) that with dual monitors you could have separate documents fully visible with one instance? I understand that only one could be Active, but you could have both documents visible? I do NOT mean split windows (obviously that is done with a single instance), but full window.

I have never used dual monitors and do not know the hows and wherefors.

Gerry
My paintings and sculpture
 
Oh. Well, in THAT case...then I am back to...a single instance is all that is really needed. Except...darn, that dialog issue. So there ya go.

Gerry
My paintings and sculpture
 
Gerry,

<<I have never used dual monitors>>
I was not impressed with the idea before I tried them but they really are great. So easy to setup on most recent laptops. Give them a try real soon.

regards Hugh,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top