Hello,
Bob wrote :
Ok, then...
OK ok I can understand the whole thing but the following code compiles fine...
...but does not work perfectly under VB/VBA (tested with Excel, wWord or Access) with the following code (after having registered the DLL and picked the TLB from the browser under Excel)
VBA Excel code trying to invoke this COM DLL (see the VBA error below)
Can you tell me what's wrong or may be the limitations within PB compiler regarding the COM support please ?
Yours,
Gerome
Bob wrote :
To make a CLASS public:
1- Make sure you have given the CLASS and each contained interface a GUID to specifically identify it.
2- Add the words "AS COM" to the end of the CLASS statement.
3- You now have a COM component.
The client programs which use this component will probably need a Type Library to get the definitions of your class, so create one with #COM TLIB ON. You mey want to embed the Type Library in the DLL using PBTYP.EXE. You'll probably need to register the COM component on each client computer that uses it. That's done with REGSVR32.EXE.
Best regards,
Bob Zale
1- Make sure you have given the CLASS and each contained interface a GUID to specifically identify it.
2- Add the words "AS COM" to the end of the CLASS statement.
3- You now have a COM component.
The client programs which use this component will probably need a Type Library to get the definitions of your class, so create one with #COM TLIB ON. You mey want to embed the Type Library in the DLL using PBTYP.EXE. You'll probably need to register the COM component on each client computer that uses it. That's done with REGSVR32.EXE.
Best regards,
Bob Zale
OK ok I can understand the whole thing but the following code compiles fine...
Code:
[FONT=Arial][SIZE=2]#COMPILE DLL[/SIZE][/FONT] [SIZE=2][FONT=Arial]#COM TLIB ON[/FONT][/SIZE] [FONT=Arial][SIZE=2]$MyClassGuid = GUID$("{00000099-0000-0000-0000-000000000008}")[/SIZE][/FONT] [SIZE=2][FONT=Arial]$MyIfaceGuid = GUID$("{00000099-0000-0000-0000-000000000009}")[/FONT][/SIZE] [FONT=Arial][SIZE=2]CLASS TESTCLASS $MyClassGuid AS COM[/SIZE][/FONT] [SIZE=2][FONT=Arial]INTERFACE DispatchIface $MyIfaceGuid[/FONT][/SIZE] [SIZE=2][FONT=Arial] INHERIT automation[/FONT][/SIZE] [FONT=Arial][SIZE=2] METHOD HideUI( BYVAL msg$ ) AS STRING[/SIZE][/FONT] [SIZE=2][FONT=Arial] METHOD = "Hello !!" & msg$[/FONT][/SIZE] [SIZE=2][FONT=Arial] END METHOD[/FONT][/SIZE] [SIZE=2][FONT=Arial]END INTERFACE[/FONT][/SIZE] [SIZE=2][FONT=Arial]END CLASS[/FONT][/SIZE]
VBA Excel code trying to invoke this COM DLL (see the VBA error below)
Code:
[FONT=Arial][SIZE=2]Sub test()[/SIZE][/FONT] [SIZE=2][FONT=Arial] Dim o As TESTCLASS[/FONT][/SIZE] [FONT=Arial][SIZE=2] o.HIDEUI '-> VBA Error 91 not an object (that is to say impossible to call the method)[/SIZE][/FONT] [SIZE=2][FONT=Arial]End Sub[/FONT][/SIZE]
Yours,
Gerome
Comment