×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Recursively scan through product structure (simple program is failing)

Recursively scan through product structure (simple program is failing)

Recursively scan through product structure (simple program is failing)

(OP)
I'm a novice programmer but new to CATIA VBA. For a starting program, I'm simply trying to traverse the current product structure and print each part number.

The code runs perfectly as a .CATSCRIPT but when loaded into a CATVBA module, it fails spectacularly.

Run time error 438 'Object doesn't support this property or method' on line 10 ' Analyze (Prod)'

Usually this means your syntax is wrong. VBA seems to have trouble passing Prod as a parameter to the subroutine.

I have verified through debugging that Prod is in fact a VarType 'Product' with a valid assignment.

Nothing I've tried has worked. Any ideas eng-tips? Thanks.

CODE -->

Public Sub CATMain()
    Dim AD As Document
    Dim Prod As Product
    
    Set AD = CATIA.ActiveDocument
    Set Prod = AD.Product
'    Debug.Print TypeName(AD)
'    Debug.Print VarType(AD)
'    Debug.Print TypeName(Prod)
'    Debug.Print VarType(Prod)
    Analyze (Prod)
End Sub
Public Sub Analyze(P As Product)
    Debug.Print P.PartNumber
    
    Dim PP As Products
    Dim i As Integer
    i = 0
    Set PP = P.Products

    Do While i < PP.Count
        i = i + 1
        Analyze (PP.Item(i))
    Loop
End Sub 

RE: Recursively scan through product structure (simple program is failing)

Try using the CALL keyword in front of the line calling your subroutine in CATMain(). VBA will only use the parenthesis around the arguments when the call keyword is used. I think CATScript ignores this syntax.

--Doug

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources