Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA as addin with new customised ribbon

Status
Not open for further replies.

Welshbird

IS-IT--Management
Jul 14, 2000
7,378
DE
So, I saved some VBA as an Excel Addin, and then used the customiseUI to create a new tab on my ribbon with a button to run my macro.

I added my add-in, and I see my new ribbon with my nice shiny button and when I click it all I get is a message that it can't find the macro.

What am I missing here guys?

Fee

"The cure for anything is salt water – sweat, tears, or the sea." Isak Dinesen
 
Aha! That was a spurious issue (calling teh macro by the name you called the macro is a good plan then...[blush])

Now however, I get an error saying
VBA said:
Wrong number of arguments or invalid property assignment

But if I step through the code its absolutely fine. So ther must be some error in the way I'm calling the macro from the button. is that the issue?

XML for button in CustomerUI designer looks like this:
Code:
<customUI xmlns="[URL unfurl="true"]http://schemas.microsoft.com/office/2009/07/customui">[/URL]
	<ribbon startFromScratch="false">
		<tabs>
			<tab id="customTab" label="Fee's Tools">
				<group id="customGroup" label="Tools">
					<button id="customButton" label="Flatten Dataview"
					imageMso="HappyFace" size = "large"
					onAction="MyMacro"  />
				</group>
			</tab>
		</tabs>
	</ribbon>

I've re-read the chapter in me book but still can't see what I've done wrong. Hopefully It's something simple!
</customUI>

Fee

"The cure for anything is salt water – sweat, tears, or the sea." Isak Dinesen
 
If I create a ribbon from the Excel interface and add the macro - its fine.

But presuambly that doesn't allow me to package this for other users.

I with I understood!

Fee

"The cure for anything is salt water – sweat, tears, or the sea." Isak Dinesen
 
Macros called from Ribbon Buttons are passed a reference to the Ribbon Button, so you need to code your macro like this ...

Code:
[blue]Public Sub MyMacro(RibbonControl As IRibbonControl)
    [green]' Put your code here![/green]
End Sub[/blue]

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Ah. So easy when someone tells you how to do it!

Doh.... Sometimes the obvious thing is missing out of my (usually) excellent book!

Thanks Tony - I'll try that later 'Ron.

Fee

"The cure for anything is salt water – sweat, tears, or the sea." Isak Dinesen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top