Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 10-25-2011, 11:28 AM
donbexcel donbexcel is offline Windows 2K Office 2007
Novice
 
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 Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 17,485
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
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
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


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
MS Works 2000 mommu Office 4 01-23-2006 02:40 PM


All times are GMT -7. The time now is 01:28 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft