Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-25-2011, 11:28 AM
donbexcel donbexcel is offline .OnAction only works in document with the code Windows 2K .OnAction only works in document with the code Office 2007
Novice
.OnAction only works in document with the code
 
Join Date: Oct 2011
Posts: 3
donbexcel is on a distinguished road
Unhappy .OnAction only works in document with the code

I'm using Word version 2007.



I created a new command bar control that calls a macro like this:
With cbcNewMenu.Controls.Add(Type:=msoControlButton)
.Caption = "ConvertTable"
.OnAction = "mod100Procs.UpdateTable"

End With

The macro only works on the document that contains the VBA code. If I try to use it on any other document I get a "The macro cannot be found... message.

I've tried this:

With cbcNewMenu.Controls.Add(Type:=msoControlButton)
.Caption = "ConvertTable"
.OnAction = "'" & Thisdocument.name & "'!mod100Procs.UpdateTable"

End With

but that doesn't work. What am I missing?
Reply With Quote
  #2  
Old 11-02-2011, 05:25 AM
macropod's Avatar
macropod macropod is offline .OnAction only works in document with the code Windows 7 64bit .OnAction only works in document with the code 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

Hi Don,

Ideally, you'd locate the macro in the document's template; otherwise you'll need to open the document holding the code before you can access it - and you'd have to reference that other document as part of the macro's call.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
PowerPoint 2010 not works Democrazy PowerPoint 0 11-26-2010 03:05 AM
VB code from one document runs on other open documents beav_35 Word VBA 0 11-10-2010 02:52 PM
Converting from Works Menno Hershberger Office 0 09-01-2010 11:33 PM
how can I add a peace of code to MS document amlife Word VBA 0 03-03-2010 03:35 PM
.OnAction only works in document with the code MS Works 2000 mommu Office 4 01-23-2006 02:40 PM

Other Forums: Access Forums

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