PROGRAM OLE_WinWordDemo; { *************************************************************************** ** Descr. : This script shows how to use OLE/ActiveX. ** In this example we are showing the files in C:\ in ** Microsoft Winword. but of course ActiveX is far more powerful ** then just using winword or excel - for example ActiveX ** also allows you to use DAO/ADO to access all kind of databases, ** to send emails using MAPI/OUTLOOK or to execute VB-Script. ** *************************************************************************** ** 03/10/01 1.001.00 Initial Creation, sm@orcl-toolbox.com ** 04/01/02 1.002.00 fixed datatypes, removed coInitialize calls, sm@orcl-toolbox.com ***************************************************************************} VAR WordApp : Variant; Range : Variant; i : number; sl : TStringList; //Begin Main BEGIN //create the winword object WordApp := CreateOleObject('Word.Application'); //make it visible WordApp.Visible := true; //create a new document WordApp.Documents.Add; //get first position on this document Range := WordApp.Documents.Item(1).Range; //write a string to this document Range.Text := 'You have following files in your C-Drive: '; //add some carriage returns for i:=1 to 3 do WordApp.Documents.Item(1).Paragraphs.Add; //get the files we would like to output and put them to the clipboard sl := GetFileList('C:\','*.*',false); StringToClipboard(sl.text); //now write to the document at the 3 line using copy/paste Range := WordApp.Documents.Item(1).Range(WordApp.Documents.Item(1).Paragraphs.Item(3).Range.Start); Range.Paste; END. //End Main