Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-16-2015, 01:16 PM
dangal333 dangal333 is offline Word VBA Macro Implementation - Please Help Windows 8 Word VBA Macro Implementation - Please Help Office 2013
Novice
Word VBA Macro Implementation - Please Help
 
Join Date: Jan 2015
Posts: 3
dangal333 is on a distinguished road
Exclamation Word VBA Macro Implementation - Please Help

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?
Reply With Quote
  #2  
Old 01-16-2015, 03:07 PM
gmaxey gmaxey is offline Word VBA Macro Implementation - Please Help Windows 7 32bit Word VBA Macro Implementation - Please Help Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 01-16-2015, 04:20 PM
dangal333 dangal333 is offline Word VBA Macro Implementation - Please Help Windows 8 Word VBA Macro Implementation - Please Help Office 2013
Novice
Word VBA Macro Implementation - Please Help
 
Join Date: Jan 2015
Posts: 3
dangal333 is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 01-16-2015, 04:54 PM
gmaxey gmaxey is offline Word VBA Macro Implementation - Please Help Windows 7 32bit Word VBA Macro Implementation - Please Help Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 01-16-2015, 05:12 PM
dangal333 dangal333 is offline Word VBA Macro Implementation - Please Help Windows 8 Word VBA Macro Implementation - Please Help Office 2013
Novice
Word VBA Macro Implementation - Please Help
 
Join Date: Jan 2015
Posts: 3
dangal333 is on a distinguished road
Default

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!
Reply With Quote
Reply

Tags
vba code



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA Macro Implementation - Please Help Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM
Word VBA Macro Implementation - Please Help Word 2003 Macro problem running in Word 2010 norwood Word VBA 2 02-03-2014 06:49 PM
Word VBA Macro Implementation - Please Help Word Macro to publish document as pdf (Word 2010) bville Word VBA 2 04-11-2013 03:30 PM
Word VBA Macro Implementation - Please Help 5 days/week during planning & 7 days/week during implementation 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:10 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft