Mega Code Archive

 
Categories / Delphi / Activex OLE
 

How do i automate word

Answer: You can get to any of the interfaces exposed by the word automation server. These can be found by loading MSWORD8.OLB into Delphi which will display the type library information. You can also use the Application's WordBasic property to get at the VB used in Word. The following sample demonstrates both avenues: implementation uses ComObj; {$R *.DFM} var V: OleVariant; procedure TForm1.Button1Click(Sender: TObject); begin V := CreateOleObject('Word.Application'); V.ShowMe; V.WordBasic.FileNew; V.WordBasic.Insert('test'); V.Run('mymac'); V.WordBasic.FileSave; end; end.