PDA

View Full Version : Creating a new tab in the ribbon and getting it working



quicksilver
02-21-2008, 03:01 AM
Hi,

im really having a hard time getting this working. What i am trying to do is create a new tab with a button so that when the user clicks the button a form will load up, i have a macro setup but it doesnt run the macro.

Macro Name: StartForms

Macro just loads up a userform on .show

Below is my xml code to create the new tab:



<customUI>
<ribbon startFromScratch="true">
<tabs>
<tab id="tabMain" label="Home">
<group id="grpProjects" label="Projects">
<button id="cmdHome" label="Home" onAction="StartForms" size="large"
imageMso="OpenStartPage" supertip="Returns the userform."/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>



When i click the button in msword i get the error code 'Wrong Number Of Arguments or Invalid Property Assignment' (Error Code 450).

fumei
02-21-2008, 11:36 AM
And you would indeed. Did you look up Arguments - the clue given by the error message - in Help?

TonyJollans
02-21-2008, 01:12 PM
I'm just learning this stuff - and I don't think you'll find much helpful in Help.

How is your VBA Sub defined? I think it should have one argument of type IRibbonControl.

quicksilver
02-22-2008, 02:01 AM
Hi,

Thanks for the replies, i solved the problem about an hour after i posted but i just thought id write how i did it incase anyone has this problem.

I went in to VBA on word and created two new modules, one called ribboncontrol and the other called macros.

In ribbon control i placed the following code:



Sub StartForms(ByVal control As IRibbonControl)
Macros.StartForm
End Sub


Note: the name 'StartForms' matches the name used in the onAction on the custom UI script.

Then in the macros module i used the following code:



Sub StartForm()

UserForm1.Show

End Sub


This script is being called by the sub startforms 'Macros.startform'.



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI>
<ribbon>
<tabs>
<tab id="CT1" label="Capleys">
<group id="Grp1" label="Forms">
<button id="Btn1" label="Start" size="large" imageMso="OpenStartPage" onAction="StartForms"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>


This was quite a simple task i was given but as i didnt know what i was doing it was a good learning curve. Im not very good at explaining what ive done but hopefully you can understand what i have written above.