![]() |
#1
|
|||
|
|||
![]()
Hello,
I have a problem with executing VBA modules that are associated to a button in the ribbon (or quick access toolbar). I have developed two VBA Word modules: "VBAMod1" and "VBAMod2" I have both of these VBA modules saved as .bas files. Here are the steps I took: 1. Open Visual Basic Editor (alt + F11) in Word 2. Right Click "Normal" & import file > "VBAMod1" (this imported to global doc) 3. Do step 2, but import file "VBAMod2" (this imported to global doc) Now I have my two VBA modules accessible globally (to tie to a button, as desired). When I go to Word Options > Customize Ribbon, I created a new "tab". I selected "Macros" on the right and have added my first and second macros to this new tab (making them executable buttons on this tab in my Word ribbon). When I try to use these two buttons (which execute two seperate modules), both buttons on this new tab of my ribbon execute only ONE module, regardless of what button was clicked. Does anyone know why it executes the WRONG module? |
#2
|
|||
|
|||
![]()
I really don't know what you are doing. Buttons on your custom ribbon don't execute modules. They execute procedures which are defined in modules. Yes, modules that are exported as files have .bas file extension and can be imported into your normal template. However, when it comes to adding macros to the ribbon, I don't see how you are adding modules. For example if you create a new module in Normal "Test" then "Test" doesn't appear in the list of available macros to add to the ribbon. However if you and a procedure in the test module e.g., "TestThisProcedure" then you should see in the list:
Normal.Test.TestThisProcedure. |
#3
|
|||
|
|||
![]()
Correct, my apologies. The buttons that are being tied to macros are executing sub routines, not modules obviously. The two different buttons I was referring two execute two seperate sub routines in two different modules:
Button1 = Normal.Module1.Subroutine Button2 = Normal.Module2.Subroutine Yet both buttons (although properly associated) execute Normal.Module1.Subroutine Any ideas? There is no problem with the imported .bas macro files into the Normal.doc(x). It seems to be associated with the way the event is created to the buttons. |
#4
|
|||
|
|||
![]()
The only way I can replicate this issue here is IF both Subroutines have the same name (as you indicate in your post). If that is the case, they can both be added to the ribbon and both execute the subroutine in the first Module1. That is, I believe, normal behavior. If they are named differently then both run.
|
#5
|
|||
|
|||
![]()
Thanks, that makes sense! Thank you very much for your help, I guess I didn't realize there was an issue with that but thanks much for that!
|
![]() |
Tags |
vba code |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
LadyAna | Word | 1 | 12-06-2014 10:39 PM |
![]() |
norwood | Word VBA | 2 | 02-03-2014 06:49 PM |
![]() |
bville | Word VBA | 2 | 04-11-2013 03:30 PM |
![]() |
sanlen | Project | 1 | 06-25-2012 04:17 PM |
Table of Contents - Direct Field Implementation - Auto-Update Numbering | ztag | Word | 3 | 01-19-2012 03:04 PM |