Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Word beenden ohne Dokument zu speichern. (https://www.delphipraxis.net/130540-word-beenden-ohne-dokument-zu-speichern.html)

ickehausen 10. Mär 2009 08:38


Word beenden ohne Dokument zu speichern.
 
Ich ersetze in ein Worddokument Textmarken mit Delphi, was auch gut funktioniert. Anschließend drucke ich es aus und möchte das Dokument ohne es zu speichern schließen. Im Moment mache ich es wie folgt:

Delphi-Quellcode:
procedure TFrmVernichtungsprotokoll.Druck;
var FileName:OleVariant;
    vWhat, vBookmark:OleVariant;
begin
  Filename := GetAPpPath + '\Vernichtung.doc';
  WordApplication1.Connect;
  WordApplication1.Documents.OpenOld(FileName, EmptyParam, EmptyParam,
  EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,EmptyParam,
  EmptyParam);
  WordDocument1.ConnectTo(WordApplication1.ActiveDocument);
  WordApplication1.Visible := True;
  vWhat:=wdGoToBookmark;
  vBookmark:='Name';
  WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
  WordApplication1.Selection.TypeText(DMMain.IBDataSetPrint.FieldByName('NNAME').AsString);
  WordApplication1.PrintOut;
  WordDocument1.Close;
  WordDocument1.Disconnect;
end;
.
.
.
procedure TFrmVernichtungsprotokoll.Timer2Timer(Sender: TObject);
begin
  WordApplication1.Quit;
  WordApplication1.Disconnect;
end;
Leider wird das Dokument dann immer mit den Inhalten der Textmarken gespeichert. Wie kann ich dass Speichern verhindern?

Progman 10. Mär 2009 08:42

Re: Word beenden ohne Dokument zu speichern.
 
Es müsste doch möglich sein, von dem aktuellen Document eine Kopie zu erstellen und damit zu arbeiten? Dann wird das originale Document ja nicht verändert ;)

Reinhardtinho 10. Mär 2009 08:43

Re: Word beenden ohne Dokument zu speichern.
 
Delphi-Quellcode:
var
  _SaveChanges : OleVariant;
begin
  ...

  _SaveChanges := False;
  WordDocument1.Close(_SaveChanges, EmptyParam, EmptyParam);
end;

ickehausen 10. Mär 2009 09:08

Re: Word beenden ohne Dokument zu speichern.
 
Danke an Euch für die schnellen Antworten. Reinhardtinho, funktioniert bestens. :bounce1: :thumb:


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:36 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz