Unable to pick the component using VBA in an assembly

Unable to pick the component using VBA in an assembly

akaluri
Enthusiast Enthusiast
586 Views
2 Replies
Message 1 of 3

Unable to pick the component using VBA in an assembly

akaluri
Enthusiast
Enthusiast

I am working on a vba form to change the 'vendor' field of a part. But I am unable to access the part's vendor propert unless I open the part in a new tab (window). If from an assembly, if I double click the part and run the rule, the vendor field of assembly is being modified. I'm sure there should be a slight modification of the following command to select the double clicked and opened part as the active file...

 

 

Dim invDoc As Document
Set invDoc = ThisApplication.ActiveDocument'Get the design tracking property set.
Dim invDesignInfo As PropertySet
Set invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties")
' Get the part number property.
Dim invPartNumberProperty As Property
Set invPartNumberProperty = invDesignInfo.Item("Vendor")
MsgBox invPartNumberProperty.Value 'Display the iproperty value

0 Likes
Accepted solutions (1)
587 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @akaluri 

If you doubble-click the part in the assembly, the assembly is still the active document.

Try changing the line:

Set invDoc = ThisApplication.ActiveDocument

To

Set invDoc = ThisApplication.ActiveEditDocument

 

That should do it 🙂

0 Likes
Message 3 of 3

akaluri
Enthusiast
Enthusiast

@JhoelForshav  Amazing! thats exactly what I was looking for. Thanks.

0 Likes