VBScript Existing Component Loop Problems
VBScript Existing Component Loop Problems
(OP)
Hello all,
I made the script to make Existing Component with Do ... Loop.
This can make just first time and after can't make it and pop up the errors.
Here is my script. Could you tell me where it is wrong?
I made the script to make Existing Component with Do ... Loop.
This can make just first time and after can't make it and pop up the errors.
Here is my script. Could you tell me where it is wrong?
CODE --> VBSCript
Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set products1 = product1.Products
Do
Dim arrayOfVariantOfBSTR1(0)
arrayOfVariantOfBSTR1(0) = "C:\tmp\Part1.CATPart"
products1.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All"
AskMsgBox = MsgBox("Whould you like to do once more?", vbYesNo, "Question")
Loop Until AskMsgBox = vbNo
End Sub 




RE: VBScript Existing Component Loop Problems
CODE --> vba
do while AskMsgBox = vbNo .... AskMsgBox = MsgBox("Whould you like to do once more?", vbYesNo, "Question") loopindocti discant et ament meminisse periti
RE: VBScript Existing Component Loop Problems
I tried to do with your script. I'm sorry but anything doesn't happen, even the Msgbox doesn't work.
So I modified yours to below script. But also this doesn't work with pop up the error.
Only 1st time can make it and after it doesn't work.
Could you tell me why it doesn't work..?
CODE --> VBScript
Do until AskMsgBox = vbNo Dim arrayOfVariantOfBSTR1(0) ' -----> Here is error line arrayOfVariantOfBSTR1(0) = "C:\Temp\Part1.CATPart" products1.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All" AskMsgBox = MsgBox("Whould you like to do once more?", vbYesNo, "Question") LoopCODE --> VBScript
Do while AskMsgBox = vbYes Dim arrayOfVariantOfBSTR1(0) ' -----> Here is error line arrayOfVariantOfBSTR1(0) = "C:\Temp\Part1.CATPart" products1.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All" AskMsgBox = MsgBox("Whould you like to do once more?", vbYesNo, "Question") LoopRE: VBScript Existing Component Loop Problems
CODE --> CATVBA
Do While AskMsgBox <> vbNo Dim arrayOfVariantOfBSTR1(0) arrayOfVariantOfBSTR1(0) = "C:\temp\Part1.CATPart" products1.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All" AskMsgBox = MsgBox("Whould you like to do once more?", vbYesNo, "Question") Loopok now with VBScript:
I change your code to
CODE --> CATScript
Sub CATMain() Set productDocument1 = CATIA.ActiveDocument Set product1 = productDocument1.Product Set products1 = product1.Products Dim arrayOfVariantOfBSTR1(0) arrayOfVariantOfBSTR1(0) = "C:\temp\Part1.CATPart" Do While AskMsgBox <> vbNo products1.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All" AskMsgBox = MsgBox("Whould you like to do once more?", vbYesNo, "Question") Loop End Suband it works. you see the added files only after you reply No.
indocti discant et ament meminisse periti
RE: VBScript Existing Component Loop Problems
Perfectly this works what I want. Now I can work!! ㅜ.ㅜ
I hope everything are going well with you!!