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;