Is there a rule to which "Item" can be chosen by both text and index? For example, the following works:
Set oBOMView = oAssy.ComponentDefinition.BOM.BOMViews.Item("Structured")
But this does not:
itemName = drawDoc.Sheets(1).DrawingViews.Item("TOP VIEW").Name
I've been looking all over, but it's hard to search given the ubuquity of the search words. Any help would be appreciated.
Thanks,
Mike
Solved! Go to Solution.
Solved by 16101972. Go to Solution.
Hi Mike,
Yes, there is a rule. Here is definition of Item property in BOMViews object
BOMViews.Item Property
Parent Object: BOMViews
Description
Returns the specified BOMView object from the collection.
Syntax
BOMViews.Item( Index As Variant ) As BOMView
Parameters
Name | Description |
Index | Input Variant value that specifies the BOMView to return. This can be either a numeric value indicating the index of the item in the collection or it can be a string indicating the name of a BOMView. If an out of range index or a name of a non-existent BOMView is provided, an error will occur. |
You can see Index is declared as variant type,and in description is written that can be a numeric value or string.
But, look at next Item property:
DrawingViews.Item Property
Parent Object: DrawingViews
Description
Returns the specified object from the collection.
Syntax
DrawingViews.Item( Index As Long ) As DrawingView
Parameters
Name | Description |
Index | Input Long value that specifies the index of the to return. |
In this property value can be only Long.
You can write you own function which return index as long type, no matter what is input (string or number)
Thanks for the explanation. I'm not sure why I hadn't seen that before. I think I will also follow your suggestion about creating my own function. I've got a lot of hard coded indices that would be better off with a string value.
Thanks again,
Mike