I am having trouble with the class modules in Femap.
In Excel, when I define a class module "CM_Nodes", and i then want to use it in my main sub, i put :
Dim oNodes As New CM_Nodes
Afterwards, when i writte "oNodes" in my sub, i get access to all the propreties.
However, in Femap, I define my class modules and save them (as .cls), i cannot use them :
API Error (Line 3): ActiveX Automation: server cannot create object.
Dim oNodes As New -->CM_Nodes
Am i missing a step to reference the class module in Femap? And if so, any tips on how to do it?
Solved! Go to Solution.
you should add your class to reference:
I think, unfortunatelly you can't choose CLS file to add to reference (but try it):
In this case you can make a class library with the free Visual Studio Express programm.
Thank you for your answer Peter.
If there is no way to link the class module (*.cls) to the main sub (*.bas), the whole class module on Femap seems pointless/useless. There must be a hidden way, or the dev would not have added it.
I can not add a class module (*.cls) file as a reference. I'll try to use the free Visual Studio Express programm to create and import the reference.
In order to add a class module, you need to reference it using a "uses" statement. Consider the following class that I've created and saved in "class1.cls":
Public Class Class1 Public Sub PrintMessage() MsgBox( "Hello World" ) End Sub End Class
In a separate file, you can reference said class using the "uses" statement:
'#uses "class1.cls" Sub Main Dim myClass As New Class1 myClass.PrintMessage() End Sub
If you don't specify a path (relative or absolute) the class module just needs to be in the same directory as your basic program.
Run the program and....