Selecting the items you just pasted via script?
Selecting the items you just pasted via script?
(OP)
I'm writing a script that lets me select a product or part to copy and paste and then translate them.
The problem I'm running into is getting the items that I just pasted as my selction to translate.
Here is an example of the code and the part that I'm having trouble is where I Set product2 = ?????
<code>
Dim Sel1(0)
Sel1(0) = "Product"
Dim Done As Integer
Dim vbYes As Constants
Dim vbNo As Constants
vbYes = 6
vbNo = 7
Done = vbYes
Do While Done = vbYes
ProdDoc.Activate
Dim SelObject As Object
Set Selection1 = ProdDoc.Selection
Selection1.Clear
vRet = Selection1.SelectElement(Sel1, "Select the Part or Product to Copy.", True)
Set SelObject = Selection1.Item(1)
Set CurProd = SelObject.Value
MsgBox CurProd.Nomenclature
ProdDoc.Selection.Add(CurProd)
Selection1.Copy
ProdDoc.Activate
Selection1.Clear
Selection1.Add Prod
Selection1.Paste
Prod.Update
Selection1.Clear
Dim product2 As Product
Set product2 = ?????
Dim move1 As Move
Set move1 = product2.Move
</code>
Any ideas?
TIA,
Puck
The problem I'm running into is getting the items that I just pasted as my selction to translate.
Here is an example of the code and the part that I'm having trouble is where I Set product2 = ?????
<code>
Dim Sel1(0)
Sel1(0) = "Product"
Dim Done As Integer
Dim vbYes As Constants
Dim vbNo As Constants
vbYes = 6
vbNo = 7
Done = vbYes
Do While Done = vbYes
ProdDoc.Activate
Dim SelObject As Object
Set Selection1 = ProdDoc.Selection
Selection1.Clear
vRet = Selection1.SelectElement(Sel1, "Select the Part or Product to Copy.", True)
Set SelObject = Selection1.Item(1)
Set CurProd = SelObject.Value
MsgBox CurProd.Nomenclature
ProdDoc.Selection.Add(CurProd)
Selection1.Copy
ProdDoc.Activate
Selection1.Clear
Selection1.Add Prod
Selection1.Paste
Prod.Update
Selection1.Clear
Dim product2 As Product
Set product2 = ?????
Dim move1 As Move
Set move1 = product2.Move
</code>
Any ideas?
TIA,
Puck





RE: Selecting the items you just pasted via script?
I guess the latest product/part will be at the bottom of the tree, so you could use a Count property of all your Product's parts or products, and the last pasted part/product would be the one you want.
Haven't tried this myself though...
-bjod
RE: Selecting the items you just pasted via script?
I tried
<code>
Dim product2 As Product
Set product2 = Prods.Count
</code>
Prods was set prior in the script As Products of the top level product.
Thanks for the try though,
Puck
RE: Selecting the items you just pasted via script?
Went back and looked at that again and it does work just had to set the item number first.
t = Prods.Count
Dim product2 As Product
Setproduct2 = Prods.Item(t)
Thanks again,
Still hitting myself over the head.
LOL,
Puck