VBA macro won't load from CUI

VBA macro won't load from CUI

Anonymous
Not applicable
3,752 Views
12 Replies
Message 1 of 13

VBA macro won't load from CUI

Anonymous
Not applicable

This macro used to work when clicked from the the AutoCAD menubar.  But now it fails. Any idea on how to get it back to working?

 

^C^C-vbarun (strcat vbapath "ChangeLayerCase.dvb!Module1.LyrChgCase")

 

Command: -vbarun
Macro name: (strcat vbapath "ChangeLayerCase.dvb!Module1.LyrChgCase") "F:\\AC2018\\vba 64 bit\\ChangeLayerCase.dvb!Module1.LyrChgCase"

Macro name:

0 Likes
Accepted solutions (1)
3,753 Views
12 Replies
Replies (12)
Message 2 of 13

Ed__Jobe
Mentor
Mentor

Can you load the file using VBAMAN? Can you then run the macro using VBARUN (not the command line verstion)? If so, check to make sure that the file, module and macro have not been renamed.

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
Message 3 of 13

Anonymous
Not applicable
Accepted solution

Yes, I can run everything from the command line.

However, I'd rather just click the menu item.

Adding the macro to the end of the command script works though. 

^C^C-vbarun (strcat vbapath "ChangeLayerCase.dvb!Module1.LyrChgCase") lyrchgcase

 

0 Likes
Message 4 of 13

Ed__Jobe
Mentor
Mentor

That's redundant. That means that the first call is loading the file, but the macro can't be found. The second attempt succeeds because the macro is now loaded. Are you sure that Module1 hasn't been renamed?

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
Message 5 of 13

Anonymous
Not applicable

As I said, it used to work, but something changed in the 2017 or 2018 versions. Adding the macro call made it work again. 

 

0 Likes
Message 6 of 13

Ed__Jobe
Mentor
Mentor

Don't you want to figure out why? Your workaround doesn't fix the original problem. It shouldn't be necessary to enter the macro name twice.

 

edit: The png shows that the folder name was changed to AC2019.

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
Message 7 of 13

Anonymous
Not applicable

^C^C-vbarun (strcat vbapath "ChangeLayerCase.dvb!Module1.LyrChgCase")

 

The vbapath variable contains the correct path to the folder.  It depends on what version of AutoCAD you are using.  Yesterday, I was running 2018, today I'm running 2019.  Both versions have the same files.

Have you tried using the command string in a menu item or are you assuming?  I have tried and it doesn't work without calling the macro function  after the -VBARUN command.

 

0 Likes
Message 8 of 13

Ed__Jobe
Mentor
Mentor

Been doing this since vba was first introduced. You never need to enter the method name twice. If you do, it's becasue the first call couldn't find it. Here is an example from the help file on the proper syntax:

Acad_Projects.dvb!Project1.Module1.Test

 

Oops, I just noticed that you didn't include the project name when you created the menu macro for the new version of acad. You only specify Module1 and the method name. Look in the Project Explorer (Ctrl+R) to find the project name. The default is "AcadProject".

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
Message 9 of 13

Anonymous
Not applicable

Here's the screenshot of the dialog based VBARUN command. The macro works when I click the Run button. Note the name of the macro, it's the same as the one I'm using. So I'm not sure what you mean by "you didn't include the project name".

0 Likes
Message 10 of 13

Ed__Jobe
Mentor
Mentor

I was editing my last post when you posted yours. Please reread 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
Message 11 of 13

Ed__Jobe
Mentor
Mentor

The VBAMAN also shows the project name along with the file/dvb.

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
Message 12 of 13

Ed__Jobe
Mentor
Mentor

@Anonymous Did you get this problem solved correctly? If my answer solved your problem, please accept it as the solution.

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
Message 13 of 13

Anonymous
Not applicable

Finally found the problem, I need two spaces (or returns) before the -vbarun and a space after lyrchgcase, indicated by the underscores below.  For some reason, -vbaload need two returns after you enter the project name.  And the return after the lyrchgcase completes the command.

 

-vbaload (strcat vbapath "ChangeLayerCase.dvb!Module1.LyrChgCase")__-vbarun lyrchgcase_

0 Likes