Board index » delphi » How do I close MSWord?

How do I close MSWord?

Hi, I have a question about releasing memory.

When I have done something with MSWord, and I wont to quit the application,
I cant get my used memory back. I loose approx. 2 % System ressources, User
resources and GDI ressources every time I open MSWord. This is what I do :

Var
  MSWord : Variant;

Begin
 MSWOrd := CreateOLEObject('Word.Basic');
 MSWord.FileNewDefault;
 (* Insert something *)
 MSWord := unassigned;
End;

When I shut down Windows, it ask me if I wont to "save changes to Document
X". X = as many times as I have called the procedure abowe.

What do I need to do to close MSWord properly and free memory?

lbhardd...@hotmail.com

 

Re:How do I close MSWord?


There is a GDI using bug in MSWord and MSExcel. So, You couldn't repair from
Delphi (even if You don't work at Redmond). Or, You Try check HWnds during
running.
Quote
ku...@image.dk wrote:
> Hi, I have a question about releasing memory.

> When I have done something with MSWord, and I wont to quit the application,
> I cant get my used memory back. I loose approx. 2 % System ressources, User
> resources and GDI ressources every time I open MSWord. This is what I do :

> Var
>   MSWord : Variant;

> Begin
>  MSWOrd := CreateOLEObject('Word.Basic');
>  MSWord.FileNewDefault;
>  (* Insert something *)
>  MSWord := unassigned;
> End;

> When I shut down Windows, it ask me if I wont to "save changes to Document
> X". X = as many times as I have called the procedure abowe.

> What do I need to do to close MSWord properly and free memory?

> lbhardd...@hotmail.com

Re:How do I close MSWord?


I would try msword.free; instead of msword := unassigned;

free releases memory resources, unassigned just changes what
msword contains.

Quote
ku...@image.dk wrote:
> Hi, I have a question about releasing memory.

> When I have done something with MSWord, and I wont to quit the application,
> I cant get my used memory back. I loose approx. 2 % System ressources, User
> resources and GDI ressources every time I open MSWord. This is what I do :

> Var
>   MSWord : Variant;

> Begin
>  MSWOrd := CreateOLEObject('Word.Basic');
>  MSWord.FileNewDefault;
>  (* Insert something *)
>  MSWord := unassigned;
> End;

> When I shut down Windows, it ask me if I wont to "save changes to Document
> X". X = as many times as I have called the procedure abowe.

> What do I need to do to close MSWord properly and free memory?

> lbhardd...@hotmail.com

Other Threads