home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1996 August
/
VPR9608A.BIN
/
del20try
/
install
/
data.z
/
AUTOCTL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-05-08
|
2KB
|
79 lines
unit AutoCtl;
{ This program demonstrates Delphi's automation control abilities by
inserting a query into a document, using Microsoft Word as an automation
server }
interface
uses Windows, Classes, Graphics, Forms, Controls, DB, DBGrids,
DBTables, Grids, StdCtrls, ExtCtrls, ComCtrls, Dialogs;
type
TForm1 = class(TForm)
Query1: TQuery;
Panel1: TPanel;
InsertBtn: TButton;
Query1Company: TStringField;
Query1OrderNo: TFloatField;
Query1SaleDate: TDateTimeField;
Edit1: TEdit;
Label1: TLabel;
procedure InsertBtnClick(Sender: TObject);
end;
var
Form1: TForm1;
implementation
uses OleAuto;
{$R *.DFM}
procedure TForm1.InsertBtnClick(Sender: TObject);
var
S, Lang: string;
MSWord: Variant;
L: Integer;
begin
try
MsWord := CreateOleObject('Word.Basic');
except
ShowMessage('Could not start Microsoft Word.');
Exit;
end;
Lang := MsWord.AppInfo(16);
with Query1 do
begin
Form1.Caption := Lang;
Close;
Params[0].Text := Edit1.Text;
Open;
try
First;
L := 0;
while not EOF do
begin
S := S + Query1Company.AsString + ',' +
Query1OrderNo.AsString + ',' + Query1SaleDate.AsString + #13;
Inc(L);
Next;
end;
begin
MsWord.AppShow;
MSWord.FileNew;
MSWord.Insert(S);
MSWord.LineUp(L, 1);
MSWord.TextToTable(ConvertFrom := 2, NumColumns := 3);
end;
finally
Close;
end;
end;
end;
end.