more simple questions
for i = 1 to 2
msgbox "here"
next i
This went into an infinite loop and I had end imagepro (alt-ctrl-del), delete the project folder and start again
.

1) why did the code fail?
2) In future if there is a run time error what is the recommended approach to stopping the code?
Apologies for this simple query
0
Best Answer
-
When your macro type is SimpleScript (created by macro recording) it's get executed right when the project is loaded (to assign all variables), so you have to use CodeCommand to insert your own code (drop it to the macro from the Toolbox) and add the code there, like this:
Public Function MySimpleMacro() As SimpleScript MySimpleMacro = New SimpleScript With Automate.ScriptingCommands.CodeCommand(MySimpleMacro) If .Run() Then ' User Code Here For i As Integer = 1 To 2 MsgBox "here" & i Next i End If End With End Function
CodeCommand ensures that your code is executed only when the macro runs.Another way is to use just normal subs or functions:Sub MySub For i As Integer = 1 To 2 MsgBox "here" & i Next i End Sub
Regards,Yuri0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions