Error message when re-purposing ribbon controls

Traitée Error message when re-purposing ribbon controls

  • Tuesday, August 07, 2012 11:40 PM
     
     

    I am trying to “re-purpose” the buttons in the Controls group to insert content controls with pre-set properties. I have created macros to insert the custom controls, and they work. (In my example below, I’m repurposing the Date Picker Content Control.)

    Here is the XML to customize the ribbon:

    <commands>
        <command idMso="ContentControlDate" onAction="PIMSmacros.RibPIMSDateControl"/>
    </commands>

    Here is the macro it calls:

    Sub RibPIMSDateControl(control As IRibbonControl)
        Selection.Range.ContentControls.Add (wdContentControlDate)
        Selection.ParentContentControl.DefaultTextStyle = "Field Text"
        Selection.ParentContentControl.DateDisplayFormat = "yyyy-MM-dd"
    End Sub

    When I load the template and click the button to insert a Date control, I get the error:  “Wrong number of arguments or invalid property assignment.”

    What am I missing?

    Thanks in advance for any help you can provide.

All Replies

  • Wednesday, August 08, 2012 10:01 PM
     
     Answered

    I figured it out. I needed to change the VBA to include additional arguments, as follows:

    Sub RibPIMSDateControl(control As IRibbonControl, ByRef CancelDefault)
        Selection.Range.ContentControls.Add (wdContentControlDate)
        Selection.ParentContentControl.DefaultTextStyle = "Field Text"
        Selection.ParentContentControl.DateDisplayFormat = "yyyy-MM-dd"
    End Sub

    I forgot to mention in the initial post that I am working in Word 2010 .

  • Thursday, August 16, 2012 9:58 AM
    Moderator
     
     

    Hi Bloomhaven-geek,

    I'm glad to hear that you have solved your issue. It might be helpful for other community members who have the similar issue to see how you solved yours.

    Best regards,
    Quist


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us