Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Menus and Toolbars / May 2008

Tip: Looking for answers? Try searching our database.

Custom Ribbon to call Macros from a template

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gandl098-00@yahoo.com - 07 May 2008 14:09 GMT
I have a bunch of macros that work great for a lot of repetative tasks
that my company performs on a regular basis.  My company just upgraded
to office 2007 and while the macros are still there and working in the
Add-Ins tab, I would like them to available in a template file that
adds a new tab.

What I have done so far is create a macro enabled template (Test.dotm)
and added my macros to this template.

One example is the macro labeled as "Commands.Cleanup"  This name
comes from the macros menu in a new document with the custom template
added in the "Templates and Addins" area.

Using the microsoft recommended program "Office 2007 Custom UI
Editor", I added the following code to test.dotm:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/
customui">
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="customTab" label="Custom Tab">
                <group id="customGroup" label="Custom Group">
                    <button id="customButton" label="Custom Button"
imageMso="HappyFace" size="large" onAction="Commands.Cleanup" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

BTW, this program changes to rels file for you, so this is done.

Now I left all the labels and icon as the default sample just to play
around, but change the onAction to Custom.Cleanup.  The new Custom Tab
now shows up in word, but clicking the icon gives me the message
"Microsoft Visual Basic: Wrong number of arguments or invalid propery
assignment".

This macro works, so that isnt the issue. Its very simple anyways. It
just fixes some spacing issues. I have even tried a simple message box
macro, and that gives me the same message.  I should also point out
that the template is in a trusted location and macro settings are on
enable all macros.

My goal is to make an easily distributable template file that can be
added in easily with a nicely laid out tab that calls my old macros.
Anyone know what I am doing wrong?
Melanie Breden - 07 May 2008 15:07 GMT
Hi,

> My goal is to make an easily distributable template file that can be
> added in easily with a nicely laid out tab that calls my old macros.
> Anyone know what I am doing wrong?

your Sub need the following argument:

Public Sub Cleanup(ctrl As IRibbonControl)
  '... your code
End Sub

or

Public Sub Cleanup(Optional ctrl As IRibbonControl)
  '... your code
End Sub

Mit freundlichen Grüssen
Melanie Breden

-MVP Excel-
Gregory K. Maxey - 08 May 2008 01:00 GMT
The information provided here might help:
http://gregmaxey.mvps.org/Customize_Ribbon.htm

> I have a bunch of macros that work great for a lot of repetative tasks
> that my company performs on a regular basis.  My company just upgraded
[quoted text clipped - 43 lines]
> added in easily with a nicely laid out tab that calls my old macros.
> Anyone know what I am doing wrong?

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.