VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

User Input Error When Running Macro From AutoCAD Button

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
1296 Views, 3 Replies

User Input Error When Running Macro From AutoCAD Button

Hello!

 

I have a problem with a macro I wrote, which I believe probably has a very simple solution that I am overlooking due to inexperience with VBA.

 

My script starts by prompting the user to select a point in the currently active drawing using this line of code: 

Location_Dist = ThisDrawing.Utility.GetPoint(, "Select distribution point: ")

This works perfectly when the code is executed from the VBA editor using the Run (F5) key, but it returns an error immediately when run from a custom button within AutoCAD.

 

The button I created calls the script using the following command:

^C^C_.-vbarun;"MyModule.DistributionScript";

This reaches the script perfectly as proven by a stop-point in the code, it always reaches the "Sub DistributionScript" line. However, as soon as it reaches the user input line I pasted above, it returns the following error:

image.png

 

I suspect the error is related to AutoCAD completely skipping over the user input part by not allowing the user any time to pick a point, thus returning an error due to empty/non-existing user input. Other scripts that require no user input run just fine using the same button code.

 

Am I calling the Macro in the wrong way? Am I asking for user input in the wrong way? Any help is greatly appreciated!

 

Regards

3 REPLIES 3
Message 2 of 4
BestFriendCZ
in reply to: Anonymous

hi,


i tested and it looks correct. Problem will be somewhere else. I got this error only if i push key after running macro... so it throws this type of exception and it is correct

...
Message 3 of 4
Anonymous
in reply to: BestFriendCZ

Thanks for your reply.

 

While that didn't really help me solve the issue, I did find this when looking around for similar pieces of code. Adding the following code fixed my problem entirely:

 

ThisDrawing.Utility.InitializeUserInput 1

I just put this before the line asking for user input, and voilá. Problem solved.

Message 4 of 4
BestFriendCZ
in reply to: Anonymous

This line disable only null user input. Question is how this input get there if you only run this macro.... but important is that problem was solved:)

...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report