Within the first If...Then block in the code I posted, there is a MsgBox with a statement in it. Within that statement is [ (" & iLogicVb.RuleName & ") ]. Just get rid of the whole section of the message, and that will get rid of the first error you are seeing. Some folks seem to have trouble with that bit of code, and some folks don't. It is simply meant to include the name of the current iLogic rule within the message, when shown, and is totally not necessary (just a bonus).
As for the second error...try changing this:
Dim oADoc As AssemblyDocument = ThisAssembly.Document
to this:
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
and see if that works better for you. It is possible, but not common, for the two to not be pointing to the same document.
Just checking though, since you said something about an add-in in your first post...you are trying to run this within Inventor as a regular iLogic rule, right (not from within Visual Studio or some other platform)? If you're attempting to run it from another platform, you may need to get the assembly document in a slightly different way, because terms like "ThisDoc", "ThisDrawing", & "ThisAssembly" are defined within the iLogic Add-in, and not available outside that setting unless specifically declared/defined.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)