Call Delphi from Word (VBA)

  1. Make your Delphi application an OLE Automation server (TAutoObject). File..New..ActiveX..Automation Object. Define your interface(s) and write the methods that you wish to call from Word.
  2. In VBA add your Delphi exe to the project. Tools..References. You should now be able to use the VBA Object Browser to (F2) to browse your Delphi functions.
  3. Code a VBA procedure to call Delphi.

Sample Code

Sub foo
  ' AutoServer is the name of the class
  ' in the object browser
  Dim MyServer as AutoServer

  System.Cursor = wdCursorWait

  Set MyServer = new AutoServer
  Call MyServer.DelphiFoo(p1, p2)

  System.Cursor = wdCursorNormal
End Sub