Custom Button not loading VBA Macro

Custom Button not loading VBA Macro

Thomas.Long
Advocate Advocate
2,035 Views
4 Replies
Message 1 of 5

Custom Button not loading VBA Macro

Thomas.Long
Advocate
Advocate

I have a button that I have installed on multiple computers that goes through and accesses ordinate dimensions and blocks in the drawing and stores their information in a separate file. Now I need to install it on the computers for another division at my workplace and suddenly the button doesn't seem to work for them. The button can be found and installed through the cui transfer easily enough, however when I press the button to make it run all I get is an error that it can't find the macro in question.

The only difference I can find between us (other than different profiles of course) is that when we press the button for the first time after opening autocad it asks us if we want to load the macro. They do not get this message. I've tried uninstalling and reinstalling it twice and am now considering instead of trying to install the old button simply generating a new one from the vba file again. Any help on why its not attempting to load the macro?

 

Thanks in advance for any help.

0 Likes
2,036 Views
4 Replies
Replies (4)
Message 2 of 5

Norman_Yuan
Mentor
Mentor

What is the macro associated to the button (toolbar button? Ribbon button? But it does not matter)? Open CUI form, find the button and look at the macro associated to it, as shown in the attached picture:CUI_Macro.png

 

 

Since the error says cannot find macro, it is probably because the VBA file (*.dvb) is not loaded. To verify whether this is the problem, you can manually load the *.DVB file first (command "VBAMAN" and then load the DVB file). After that, try the button. If it works, then that is the problem: you need to load the DVB file first.

 

You can use Acad.dvb to make sure your custom *.DVB file being loaded on AutoCAD's startup. 

 

A even more simpler solution is update the button's macro with "(vl-vbarun "myVbaProgram.dvb!MyModule.MyMacro"), just as the same as shown in the picture. As you can see, the argument passed to (vl-vbarun ....) includes the DVB file name. Thus, when the button clicked, the VBA file will be loaded first, if it hasn't been loaded before. Note, the VBA file MUST be loaded with one of the support paths, so AutoCAD can find the DVB file. Alternatively, you can include full path of the file: ^C^C(vl-vbarun "C:/MyCadResources/MyVbaApps/myVbaprogram.dvb![Module].[Macro]").

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

Ed__Jobe
Mentor
Mentor

Does the other division have read rights to the dvb? Your IT dept may not have given them rights to see the file location where you stored the dvb.

 

BTW, its asking you if you want to load the macro because you don't have the dvb's location in the TrustedLocations variable. Check the Files tab of your options.

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 4 of 5

Thomas.Long
Advocate
Advocate

It's kinda awkward. They got mapped to the drive but don't have rights to write to it and can't see when new folders are added but any new files that are added to existing folders can be seen.  I'm not sure exactly how it works. I will see if I can add it to trusted locations though. Thank you.

0 Likes
Message 5 of 5

Thomas.Long
Advocate
Advocate

Thanks, I didn't know you could autoload it with the macro rather than having it ask. I'll try this in the afternoon when I get on with them to attempt again.

0 Likes