PDA

View Full Version : Help using activeX controls in VBA code



bdouglasoz
10-14-2008, 11:50 PM
Hi,
I've been using VBA for some time but have never worked with ActiveX controls.
I am trying to use an ActiveX Control that creates graphs (NTGraph3E) in Excel from a website called codeproject.com - the 3D Graph ActiveX Control.
I have registered the dll using REGSVR32.
I created an ActiveX control using the NTGraph3D class from the list.
I can see the empty x,y,z axis in the control.
I double-clicked on the control to add code.
I have ensured that I've ticked "NTGraph3D 1.0 Type Library" in my project References.
I can see the NTGraph3D objects when I open the object browser.
I have created the following test code:
Sub TstTorus()
Dim Gr As OLEObject
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
WS.OLEObject("NTGraph3D").ClearGraph
End Sub
I keep getting the same compile error:
Object library invalid or contains references to object definitions that could not be found.
Is there some step that I've missed? I would greatly appreciate help!:banghead:
bd

Bob Phillips
10-15-2008, 01:14 AM
Is this a .Net control? Perhaps you don't have the correct .Net framework? Do you have a link to the control?

bdouglasoz
10-15-2008, 03:11 PM
Hi,
Thank you for looking at this.
The developer specified on his web page:
"To use this control, embed it in an application that supports the use of ActiveX controls. Microsoft Visual Basic applications, all MS Office applications, VBScript and JavaScript in the HTA or Internet Explorer applications, and applications created with the Microsoft Developer Studio?s AppWizard can support the use of ActiveX controls."
So, I am assuming that it is not a .Net control. I'm unable to post links on this forum at this point as I am new. I've attached the source code and dll from his site.
Cheers

Bob Phillips
10-15-2008, 03:48 PM
Just type the link as text then, it will be easier to take a look.

bdouglasoz
10-15-2008, 04:18 PM
Hi, spaces inserted in order to get around the limit on not pasting a link
www .codeproject .com /KB /openGL /ntgraph3d_atl .aspx

bdouglasoz
10-15-2008, 04:33 PM
An interesting discovery - I am able to use this control without difficulty in MSAccess 2003 (am using Excel 2003). So, I have a workaround. I'll be able to import my graph data into Access and then generate the graph there. However, I'm still frustrated that Excel won't recognise the object library.

In MSAccess I was able to register the ActiveX Control through a menu option Tools -> ActiveX Controls ...