Using SendCommand twice results in a run-time error "Invalid execution context"

Using SendCommand twice results in a run-time error "Invalid execution context"

Anonymous
Not applicable
4,900 Views
27 Replies
Message 1 of 28

Using SendCommand twice results in a run-time error "Invalid execution context"

Anonymous
Not applicable

I'm really hoping that someone can help.

 

I just upgraded from AutoCAD 2015 to AutoCAD 2016 and now my VBA App (which I spent the last several months developing) won't work. Here is the issue. Keep in mind that this all ran flawlessly in AutoCAD 2015.

 

There are a couple of places whereI have to use the SendCommand function due to a VBA method not being available or the users wanting visual feedback (gohsting and what-not) that you can't do in VBA. Whenever I use the SendComman more than once it results in this run-time error.

 

Error.JPG

 

Here is some example code:

 

Sub test()
    ThisDrawing.SendCommand "(command ""PLINE"")" & vbCr
    
    ThisDrawing.SendCommand "(command ""PLINE"")" & vbCr '<- This line errors
End Sub

If i run this from AutoCAD using:

-VBARUN "test"
or
(vl-vbarun "test")

it results in the error above whne trying to run the second SendCommand. The first SendCommand run fine. I've tried seperating them out into different sub routines but the result is the same.

 

Here is the intersting part. If I exectur this code from the VBAIDE it runs perfectly fine. The error only occurs when I execute it from AutoCAD.

 

Any help would be greatly apriciated. Thanks!

 

0 Likes
Accepted solutions (2)
4,901 Views
27 Replies
Replies (27)
Message 21 of 28

Anonymous
Not applicable
Any Idea how long till this bug is fixed?
0 Likes
Message 22 of 28

falk_graupner
Explorer
Explorer

We have exactly the same problem and need the "SendCommand"-functionality.

Please hurry up with the BugFix.

0 Likes
Message 23 of 28

Anonymous
Not applicable

Does anyone know if this problem exists in AutoCAD 2017?

0 Likes
Message 24 of 28

paulleinweber
Participant
Participant
I was able to roll back (uninstall) the service pack and resolve the issue in my environment.
0 Likes
Message 25 of 28

Anonymous
Not applicable

It works in AutoCAD 2017.  I've just done a preliminary test with the free trial version of 2017.  It appears to work with multiple SendCommand executions.

 

David

0 Likes
Message 26 of 28

Anonymous
Not applicable

Does anyone know if AutoCAD 2016 Hotfix 3 fixes this problem?

 

https://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/autodesk-C2-AE-autoc...

 

David

0 Likes
Message 27 of 28

falk_graupner
Explorer
Explorer

Yes, it works.

Message 28 of 28

snumedahl
Explorer
Explorer

I too can also confirm that the Hotfix works.

0 Likes