1

I am a novice when it comes to CATIA, but I have a fair amount of experience with VBA in excel. I am trying to develop an excel macro that goes through the all the parts in a catia assembly, renames them by splicing the text where i want, and then reorder them (alpha-numeric ascending order). I believe I can write the algorithm for the actual splicing, renaming, reordering bit. What I am struggling with is actually operating Catia using excel. There is not a lot of information on the internet. I have ticked all the boxes in the references section that start with CATIA. I have written this so far:

Dim CATIA as object
Set CATIA = Getobject(,"CATIA.Application")
Dim oMyDoc as Document
Dim oCurrentProd as Product   'I assume the individual parts within CATIA are_
                               referenced as products?
Set oMyDoc = CATIA.ActiveDocument

If I try and run just the above code, I get an error saying 'Class doesn't support Automation'. Which means my basics are wrong. Would appreciate help on this and any other information that would enable me to complete my task. Thanks.

Community
  • 1
  • 1

1 Answers1

0

When running a code from CATIA in VBA, some objects gets an error when they are properly typed. Try declaring those objects without a type or as a variant.

Dim CATIA as 'object
Set CATIA = Getobject(,"CATIA.Application")
Dim oMyDoc as 'Document
Dim oCurrentProd as 'Product   
Set oMyDoc = CATIA.ActiveDocument

or

Dim CATIA as variant
Set CATIA = Getobject(,"CATIA.Application")
Dim oMyDoc as variant
Dim oCurrentProd as variant   
Set oMyDoc = CATIA.ActiveDocument

I recommend you to first declare them properly typed so you can see the object's methods and properties and afterwards change it to variant

Quima
  • 894
  • 11
  • 21