Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-07-2019, 10:19 AM
josh2008 josh2008 is offline Is it possible to call a common vba macro on a commandbutton ? Windows XP Is it possible to call a common vba macro on a commandbutton ? Office 2016
Novice
Is it possible to call a common vba macro on a commandbutton ?
 
Join Date: Feb 2019
Posts: 2
josh2008 is on a distinguished road
Default Is it possible to call a common vba macro on a commandbutton ?


Hi
Hope this can be done is Word etc (I can in LibreOffice etc).
I wish to use many command buttons in a document, these buttons basically control external hardware. I would need to call a VBA code that gets the caption from the sending button and then send this caption to a shell program.

I can create a button, but I cannot assign any events as such, I can create the code; but this for each button.


I would like to be able to copy paste a button, and just change the caption for the new button for it to work.


I cannot find a way to use a custom macro with the button click event.


Button I am using, is Legacy CommandButton


Hope that makes sense.
Reply With Quote
  #2  
Old 02-07-2019, 11:42 PM
gmayor's Avatar
gmayor gmayor is offline Is it possible to call a common vba macro on a commandbutton ? Windows 10 Is it possible to call a common vba macro on a commandbutton ? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Select Design Mode from the Controls group. Right click the button > View Code. Use that code to call your macro.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 02-08-2019, 02:02 AM
josh2008 josh2008 is offline Is it possible to call a common vba macro on a commandbutton ? Windows XP Is it possible to call a common vba macro on a commandbutton ? Office 2016
Novice
Is it possible to call a common vba macro on a commandbutton ?
 
Join Date: Feb 2019
Posts: 2
josh2008 is on a distinguished road
Default

Hi


Thanks for your reply, but that is doing exactly what I do not want to do.

I would like to be able to copy and paste a button, then change its caption and then for it to work, without having to go in and change the code.


I have also found no way for the code to interrogate the sending buttons properties as the application.caller does not appear to be available in word, yet is in excel
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find word then call signature macro Dave T Word VBA 4 03-28-2016 11:18 PM
Is it possible to call a common vba macro on a commandbutton ? Word 2013: Hotkey to call a macro arjfca Word 2 12-04-2014 12:53 AM
Is it possible to call a common vba macro on a commandbutton ? Need help with sorting a column by most common to least common mikenmike0001 Excel 5 12-06-2011 05:17 PM
Is it possible to call a common vba macro on a commandbutton ? Call Macro from Input Box String Paulsh Word VBA 1 11-01-2011 03:15 AM
Is it possible to call a common vba macro on a commandbutton ? How do I call/execute an Excel macro from Access 2003 KramerJ Excel 2 05-11-2009 11:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:30 AM.


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