Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Olsndot
1087 Views, 5 Replies

Editing component in sub assembly error with VBA

Hi,

I have trouble with elementary code in VBA.
That code is to edit component as shown in the below.
It works in top assembly,but doesn't work in editing sub assembly from within top assembly.

What exactly needs changed to allow this to work?

 

Sub EDIT_COMPONENT()

Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveEditDocument

Dim oAsmCompDef As ComponentDefinition
Set oAsmCompDef = oAsmDoc.ComponentDefinition

Dim oOcc As ComponentOccurrence
Set oOcc = oAsmCompDef.Occurrences.Item(1)
oOcc.EDIT
End Sub