Make VBA macro reliable

Make VBA macro reliable

ofk15sar
Observer Observer
1,103 Views
1 Reply
Message 1 of 2

Make VBA macro reliable

ofk15sar
Observer
Observer

So I have written a macro that fills a title block with information (only text) and it works fine on my PC. The user enters information into a form and then the information is written to the AutoCAD model view by using SendCommand Methods, something like this:

 ThisDrawing.SendCommand "loremIpsum" & vbCr ....

 ThisDrawing.SendCommand "loremIpsum2" & vbCr ....

 ThisDrawing.SendCommand "loremIpsum3" & vbCr ....

 

I guess this is not a very reliably way of writing information because when some of my peers try to run it on their computers it doesn't work as expected. The problems start when the macro comes to SendCommand lines, it gets out of sync or something and nothing is written. The macro works for some and others just have problems. 

 

Atm we are all using AutoCAD 2016 on our windows computers so it can't be a version issue? To me it seems that they are using other Autocad settings than I am, perhaps how commands are entered or something. 

 

I would like to get some advice how I can make my macro more stable so it works for everyone. Perhaps there is a third party application/environment that I can control and run the macro from, Any suggestions is welcome 🙂

 

BG

 

 

 

 

0 Likes
1,104 Views
1 Reply
Reply (1)
Message 2 of 2

Ed__Jobe
Mentor
Mentor

From developer help

This method is generally synchronous. However, if the command sent with this method requires any user interaction (such as picking a point on the screen) then this method will continue as soon as the user input begins. The command will then continue to be processed asynchronously. When this method is called from an event handler it is processed asynchronously.

 Generally, its better to use the api do directly manipulate the model rather than use SendCommand, especially since it can sometimes run asynchronously. That said, I can't tell what your code is doing from the sample you posted. You would need to post your code for help with it.

Ed


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.
How to post your code.

EESignature

0 Likes