unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Clipbrd, StdCtrls, Word2000, OleServer;
type
TForm1 = class(TForm)
Button1: TButton;
WordApplication: TWordApplication;
WordDocument: TWordDocument;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
sl:TStringlist;
sysClip:TClipboard;
begin
sl := TStringList.create;
SysClip := TClipboard.create;
try
try
WordApplication.Connect;
except on E:Exception do begin
MessageDlg('Word may not be installed', mtError, [mbYes], 0);
Abort;
end;
end;
WordApplication.Visible := True;
WordApplication.Caption:='DevSuperPage.com';
//Create new document
//Turn Spell checking off because it takes a long time if enabled and slows down Winword
WordApplication.Options.CheckSpellingAsYouType := False;
WordApplication.Options.CheckGrammarAsYouType := False;
sl.LoadFromFile('c:\test.txt');
SysClip.AsText :=sl.Text;
SysClip.Free;
sl.Free;
WordDocument.Sentences.Last.Paste;
except on E:Exception do begin
Application.ShowException(E);
WordApplication.Disconnect;
end;
end;
end;
end.