Word 2000 COM Close Document

Hi,

I have a stable application for word97.

Recently the company changed to word2000. And a specific pain has crept into my application:

WordApp.Documents.Open(LoadFileName);
cool no problems

WordApp.Documents.Item(0).Close(0);
Wordapp.quit;

here word2000 prompts this message:
"This file is in use by another application or user. \blahblah\Normal.dot"

How can I exit cleanly without having to go through this message?

Rob ;-)

P.S.
(I think this is vladika territory)





LVL 7
RBertoraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

florisbCommented:
procedure closeWord(saveChanges:boolean);

var
SvChngs, OriginalFormat, RouteDocument: olevariant;
GWord80: _Application;

begin
GWord80 := CoApplication.Create;

//open template, et cetera
//<your code here>

if SaveChanges then
  SvChngs:= wdSaveChanges
else
  SvChngs := wdDoNotSaveChanges;
OriginalFormat :=OriginalDocumentFormat;
RouteDocument := 0;
GWord80.Quit(SvChngs, OriginalFormat, RouteDocument);
end;

This is how I close Word, this code is happy implemented in a working product..... ....answer Okee....?

greetings,
Floris.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RBertoraAuthor Commented:
OriginalDocumentFormat;
is not declared..
Rob ;-)
0
florisbCommented:
{ WdOriginalFormat }

  wdWordDocument = 0;
  wdOriginalDocumentFormat = 1;
  wdPromptUser = 2;

So just use 1...
....I copy pasted these constants from the imported Word8 type library, but the code above works for Word 97 and 2000.

Good luck and I'm looking forward for some points... ..did you manage to print yet...?

(all vars Olevariants):
Background             := True;
Append                 := False;
Range                  := wdPrintAllDocument;
PrintToFile            := False;
OutputFileName         := '';
From                   := '1';
To_                    := '32767';
Item                   := wdPrintDocumentContent;
Copies                 := 1;
Pages                  := '';
PageType               := wdPrintAllPages;
Collate                := True;
FileName               := '';
ActivePrinterMacGX     := '';
ManualDuplexPrint      := False;
GWord80.PrintOut(Background, Append, Range, OutputFileName, From, To_, Item, Copies, Pages, PageType, PrintToFile, Collate, FileName, ActivePrinterMacGX, ManualDuplexPrint);


:-)


Greetings,
Floris.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

RBertoraAuthor Commented:
Thanks very much!

I'm sure I could have figured it out but right now didn't have the time, and
this is exaclty why EE is here!

Rob ;-)
0
florisbCommented:
Thanks for the points...:-)

And good luck,
Floris
0
RBertoraAuthor Commented:
Pleasure,
g'luck to you too
:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.