3

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?

Daniel Lemke
  • 1,966
  • 18
  • 24
Jeremy
  • 145
  • 1
  • 3
  • 9

1 Answers1

1

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.

Olle Sjögren
  • 5,315
  • 3
  • 31
  • 51
  • I used this tool to build the XML: http://www.andypope.info/vba/ribboneditor.htm I have tried changing the tags to mso:ribbon, etc and changing the schema to the 2009 (latest) version, with no effect. If I place this XML in an Excel file (the same way that Custom UI Editor does), it loads correctly. – Jeremy Aug 07 '12 at 19:22
  • 1
    If you open the project-file in Custom UI Editor and klick the Generate Callbacks-button to get the VBA signatures - do they look the same as for the Excel-file? – Olle Sjögren Aug 08 '12 at 06:58
  • I cannot open the Project file in the Custom UI Editor because Project 2010 does not conform to the Office Open XML file format. In Project, Ribbon XML cannot be inserted into to a Project file; it must be loaded using the SetCustomUI VBA method. – Jeremy Aug 10 '12 at 04:28
  • OK, I guess my comments only apply to Excel, Word and PPT. I did find this, though: http://social.msdn.microsoft.com/Forums/en-US/officegeneral/thread/e9ecd0be-73b9-407f-a608-45a76d9eeafc There it says that callbacks only work with VSTO and not VBA in Project. – Olle Sjögren Aug 10 '12 at 20:55
  • Yeah, I suspected that was the case. Glad to see it confirmed by others, though. Too bad Microsoft does not mention that limitation in the articles linked to in my question. – Jeremy Aug 12 '12 at 01:21