Home > Back-end >  Consult the Delphi WORD problems in operation
Consult the Delphi WORD problems in operation

Time:10-22

While I'm in the middle of using Delphi operations WORD set to not show, but the Documents. When closing the Close is there will be a show WORD interface, a flash, I don't know which colleague know how to solve? Thank you for your guidance!
The code is as follows:

WordApp:=CreateOleObject (' Word. Application);
WordApp. Visible:=False;
WordApp. Documents. The Open (' d: \ test. Doc);
.
WordApp.. The Documents. The Close (False);//this guild to appear the interface for shows a WORD, a flash
WordApp. Quit;
WordApp:=the Unassigned;

CodePudding user response:

 procedure TForm13. Btn2Click (Sender: TObject); 
Var
WordApp WordDoc: OleVariant;
The begin
Try
WordApp:=CreateOleObject (' Word. Application);
Except on E: the Exception do
Raise the Exception. The Create (' Error Message ').
end;

WordApp. Visible:=False;
WordDoc:=WordApp. Documents. The Open (' c: \ cc. Doc);
Try
WordApp. Selection. TypeText (students' evaluation of teaching results');
WordApp. Selection. TypeParagraph;//enter

WordDoc. Saveas (' c: \ cc. Doc);
The finally
WordDoc. Saved:=True;
WordDoc. Close;
WordApp. Quit;
end;
ShowMessage (" ok ");
end;

CodePudding user response:

reference 1st floor simonhehe response:
Delphi/Pascal code? 123456789101112131415161718192021222324 procedure TForm13. Btn2Click (Sender: TObject); Var WordApp WordDoc: OleVariant; Begin the try WordApp:=CreateOleObject (' Word. The App...

I just read, read only, do not write, and not kept

CodePudding user response:

refer to the second floor ganlnyn2008 response:
reference simonhehe reply: 1/f, Delphi/Pascal code? 123456789101112131415161718192021222324 procedure TForm13. Btn2Click (Sender: TObject); Var WordApp WordDoc: OleVariant; Begin the try WordApp:=Crea...


 procedure TForm13. Btn2Click (Sender: TObject); 
Var
WordApp WordDoc: OleVariant;
The begin
Try
WordApp:=CreateOleObject (' Word. Application);
Except on E: the Exception do
Raise the Exception. The Create (' Error Message ').
end;

WordApp. Visible:=False;
WordDoc:=WordApp. Documents. The Open (' c: \ cc. Doc);
Try
WordApp. Selection. TypeText (students' evaluation of teaching results');
WordApp. Selection. TypeParagraph;//enter

//WordDoc. Saveas (' c: \ cc. Doc);//hide the can
The finally
WordDoc. Saved:=True;
WordDoc. Close;
WordApp. Quit;
end;
ShowMessage (" ok ");
end;
  • Related