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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
florisbConnect With a Mentor Commented:
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
 
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
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
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
All Courses

From novice to tech pro — start learning today.