2
votes

[ToDo] (1) As indicated from NGLN's helpful answer, using simpler keywords such as "Delphi ActiveX control" to search. (2) Consuming the ActiveX control in Word/Excel/Powerpoint is yet another step. [/ToDo]

[Useful links]

Writing ActiveX Controls in Master Delphi 7

create non visual activex control with delphi

Error Could not load unit [unit] symbol information for [TClassName]

=======

Or what books and courses to learn if I want to write in Delphi a well-behaved ActiveX control which can be used in Microsoft Word/Excel/Powerpoint ?

Very sorry if this should be a bad question without programming details. However, when I search in the internet materials, almost all I get is about "how to manipulate/embed/host Word/Excel/Powerpoint in Delphi application". Is it because there are other languages/toolkits best suited for creating ActiveX controls which can be used in Microsoft Word/Excel/Powerpoint ?

The reason why I am trying:

  • What I do now : (1) A Delphi application is used to produce a image file. (2) This image file is pasted in a Excel report. (3) When different representation of the image is needed, one repeat (1) and (2). That is to say, one need to switch between applications.

  • My goal is to have : (1) A Delphi ActiveX is embeded/hosted in a Excel report. When different representation of the image is needed, one can thus manipulate through the Delphi ActiveX within the Excel report, and do not need to go elsewhere or switch between applications.

1
Are you 100% sure that putting ActiveX controls in Office is what you want to do? What is your goal?David Heffernan
@DavidHeffernan Thank you for your efforts! I will put better description above.SOUser
Please don't add answers to your question. Post an answer instead.NGLN
What answer ? The only one answer is yours, which is helpful . I am merely revising the original post, without compromising the purpose or stupidity of the original question .SOUser
(1) Please address a user with @ when you want to address that user. (2) You ask for books/courses dealing with writing ActiveX controls. It seems you found some links that answer exactly that. You added those links to the question above, they should be in an answer. Please add an answer to this (yes, your own) question. Gain reputation and/or badges with it, and remove the links, the strike-trough and that silly ToDo-list from the question. Follow the simple rules of SO, you are around long enough to be familiarized with them by now for sure.NGLN

1 Answers

3
votes

You can create an ActiveX control by following these steps:

  • Design your control as installable component, inherit from TWinControl or below
  • Publish properties you want to use, once as ActiveX control
  • Add it to a registerable package
  • Install that package into the Delphi IDE
  • Close all
  • Choose File > New > Other... > ActiveX > ActiveX Library
  • Choose File > New > Other... > ActiveX > ActiveX Control
  • Choose your component from the VCL Class Name combo box
  • Set the threading model you want to support. Apartment is the default and probably preferrable.
  • Build the project
  • Register the OLE Control Extension (.ocx) that Delphi created with regsvr32.exe

That is how I added a Delphi DXF control to an Access database:

enter image description here

Note that you will need a 64-bit ocx for a 64-bit MS Office installation (regardless of the Windows version).

For reference: the chapter in the documentation dealing with creating COM objects starts here.