2
votes

I have added a tab to the Ribbon in MS Project 2010 using the SetCustomUI VBA method as detailed here: http://msdn.microsoft.com/en-us/library/ee767705.

The tab XML loads fine and the layout is set up properly. The problem is when executing the VBA callbacks associated with my buttons and editBoxes, Project does not seem to be using the standard method signatures defined here: http://msdn.microsoft.com/en-us/library/aa722523.aspx#a16c7df5-93f3-4920-baa8-7b7290794c15_Ribbon.

These signatures work in the "more standard" Office programs like Excel 2010, but when I write the methods with the same parameters in Project, I get exception pop-ups unless I remove all parameters from the method. This is okay for buttons (which are demonstrated in the first MSDN article), but for the "onChange" callback for editBoxes, with no arguments provided in the callback, I have no way to read what text has been entered in the editBox, making them useless. How is the content of a Ribbon editBox supposed to be accessed in Project? Has VBA access to this String just been overlooked in Project? Can it only be accessed with Managed Code?

Here's an example of an XML / VBA pair I've tried:

<customUI  xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon >
        <tabs >
            <tab 
                id="NavHelper"
                label="Nav Helper">
                <group 
                    id="Group1"
                    label="Search">
                    <box  id="Box1" >
                        <editBox 
                            id="DateBegin"
                            label="Dates from"
                            sizeString="11/11/1111"
                            onChange="DateBegin_onChange"/>
                        <editBox 
                            id="DateEnd"
                            label="to"
                            sizeString="11/11/1111"
                            onChange="DateEnd_onChange"/>
                    </box >
                    <button 
                        id="doSearch"
                        imageMso="InstantSearch"
                        label="Search"
                        size="large"
                        onAction="doSearch_onAction"/>
                </group >

            </tab >
        </tabs >
    </ribbon >
</customUI >

And the VBA:

Public Sub DateBegin_onChange(control As IRibbonControl, text As String)
    MsgBox text
End Sub

Public Sub doSearch_onAction(control As IRibbonControl)
    MsgBox "pressed!"
End Sub

So with this example, the set up works perfectly in Excel, but if I bring it to Project, the callbacks won't run unless I remove all of the parameters from the method definitions, at which point they run, but are useless. Any ideas?

1

1 Answers

1
votes

Have you tried the Custom UI Editor for Microsoft Office?

See http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/06/7293.aspx

I haven't worked in MS Project, but in the other office programs you can enter the customUI XML and validate it and also get the corresponding VBA-function signatures.

If I try your customUI XML in Excel and try to validate (I don't have Project...), I get an error saying the namespace is wrong.