Hey
If you intend to use code either in VBA or iLogic, it would be best for you to read up / watch some youtube videos about it to get a better understanding. To explain my code:
In your image you have 2 red highlighted portions of code. this indicates an error on those lines. My code fixes each section. to explain what the differences are:
iLogic code can be constructed in a single line in the same way vb.net can. The object is created and instantiated like this
Dim oDoc As document = ThisApplication.ActiveDocument
This line of code in simple terms is taking the active document (the one you can see) from the currently open instance of Inventor, creating a code version of the document (oDoc) and setting as the active document.
In VBA, you cannot construct and instantiate an object like you can in iLogic or vb.Net, it must be done in 2 separate lines:
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
or
Dim oDoc As Document: Set oDoc = ThisApplication.ActiveDocument
Using the colon as a separator to allow the 2 commands on the same line.
For the message box, code in general requires you fully qualify the code line. you can return the code down to a new line but only if you tell the code what you are doing. for example:
Valid messagebox
MsgBox ("here is some text"), vbOKCancel, "My title"
Valid messagebox
MsgBox ("here is some text"), _
vbOKCancel, _
"My title"
Invalid messagebox
MsgBox ("here is some text"),
vbOKCancel,
"My title"
The underscore is telling the code line that it continues below. without it, the code line is unfinished and unaware there is more code underneath to complete the method.
In your case, the inputbox was missing the underscore
Hope that helps, i would strongly advise looking into some coding help files if you're going to be looking at code solutions.
Thanks
Nacho
Automation & Design Engineer
Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.