none
Custom Macro Buttons Don't Work RRS feed

  • Question

  • Thank you for taking the time to read my question.

    I have created the following CustomUI for Word 2010. I have edited my onAction to a Sub called Test... for testing purposes to figure out why I'm getting an error.

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    	<ribbon>
    		<tabs>
    			<tab id="GHSTab" label="GHS Tab">
    				<group id="GHSGroup" label="GHS Group" insertAfterMso="Developer">
    					<button id="GHS" label="GHS Button" image="exclamation_mark_sm" size="large" onAction="Test" />
    					<button id="GHSnd" label="GHS ND Button" image="exclamation_mark_nd_sm" size="large" onAction="Test" />
    				</group>
    			</tab>
    		</tabs>
    	</ribbon>
    </customUI>


    Before I changed the onAction to "Test" the buttons referred to other Sub's that also do not have anything in the ()'s.

    When I click either of the buttons I get: "Wrong number of arguments or invalid property assignment"

    This is the Test sub

    Sub Test()
    MsgBox "Hi"
    End Sub

    I tried Public Sub and Sub both with the same result.

    There are no arguments. I don't know what "property" means.

    I can run the macros fine manually in the VBA Editor, just not from the UI Buttons.

    Any help would be great.

    Thanks,
    Brad


    • Edited by mbrad Monday, March 26, 2018 2:46 PM
    Monday, March 26, 2018 2:45 PM

Answers

  • Hello mbrad,

    The callback function for button OnAction need a parameter IRibbonControl.

    Code should be this.

    Sub Test(control As IRibbonControl)
    MsgBox "Test"
    End Sub

    Please use the Generate Callback button to check the parameters format.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by mbrad Tuesday, March 27, 2018 1:02 PM
    Tuesday, March 27, 2018 1:42 AM

All replies

  • Hello mbrad,

    The callback function for button OnAction need a parameter IRibbonControl.

    Code should be this.

    Sub Test(control As IRibbonControl)
    MsgBox "Test"
    End Sub

    Please use the Generate Callback button to check the parameters format.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by mbrad Tuesday, March 27, 2018 1:02 PM
    Tuesday, March 27, 2018 1:42 AM
  • Thank you so very much Terry! That was it!

    I did not have to do this for Excel so did not even consider it. 

    Have a great day,
    Brad

    Tuesday, March 27, 2018 1:02 PM