Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-25-2018, 02:04 AM
sg11 sg11 is offline Calling a macro from a template using OnAction Windows 7 64bit Calling a macro from a template using OnAction Office 2010 64bit
Novice
Calling a macro from a template using OnAction
 
Join Date: Mar 2018
Posts: 5
sg11 is on a distinguished road
Default Calling a macro from a template using OnAction

I have created a template called "Sandra Macros.dotm"
I have created a custom menu to call a procedure in this template

Set myCmdBarCtl = myCommandBar.Controls.Add(msoControlButton)
with myCmdBarCtl
.BeginGroup = True
.OnAction = "=SaveAllImages()"


End with

I attach the template to the current document

If I move the procedure SaveAllImages() to Normal.dotm the button works. If not I receive an error " The macro cannot be found or has been disabled because of macro security setting" - The macro security is low ... it works when in Normal.dotm.
How should I indicate to "OnAction" to search in the template? tried adding the template name .. did not work
Reply With Quote
  #2  
Old 04-25-2018, 02:41 PM
macropod's Avatar
macropod macropod is offline Calling a macro from a template using OnAction Windows 7 64bit Calling a macro from a template using OnAction Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That's because the command button is still looking for its macro in the original template; you'd need to recreate the command button in the Normal template.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-30-2018, 11:43 PM
sg11 sg11 is offline Calling a macro from a template using OnAction Windows 7 64bit Calling a macro from a template using OnAction Office 2010 64bit
Novice
Calling a macro from a template using OnAction
 
Join Date: Mar 2018
Posts: 5
sg11 is on a distinguished road
Default

The problem is that the macro is a tool that people need to use on different documents. When they want to use the macro they will attach the macro to their document and use it. This template will not be attached automatically. It should be used on demand
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a macro from a template using OnAction Macro added to Ribbon in template does not appear after attaching template rocky2 Word VBA 1 04-04-2016 12:00 AM
#REF Error when calling VBA Function RodneyJ Excel Programming 1 01-21-2016 12:42 PM
Calling a macro from a template using OnAction Calling a macro in powerpoint from command line SeattleITguy PowerPoint 4 11-26-2014 01:41 AM
Calling a macro from a template using OnAction .OnAction only works in document with the code donbexcel Word VBA 1 11-02-2011 05:25 AM
Re-Calling Sent Email freschij Outlook 1 12-06-2010 09:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:53 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