问题
[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:
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:
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.
来源:https://stackoverflow.com/questions/19112324/how-to-write-delphi-activex-control-which-can-be-used-in-ms-word-excel-powerpoin