+ Reply to Thread
Results 1 to 3 of 3

Customize Ribbon Code. Need Help!

Hybrid View

Hooty Customize Ribbon Code. Need... 02-07-2013, 02:30 PM
JosephP Re: Customize Ribbon Code.... 02-07-2013, 03:51 PM
Hooty Re: Customize Ribbon Code.... 02-08-2013, 12:45 PM
  1. #1
    Registered User
    Join Date
    10-25-2012
    Location
    Ne/Ia
    MS-Off Ver
    office 2016
    Posts
    52

    Customize Ribbon Code. Need Help!

    I found a Very useful macro so i added it to several that i want to create an add in for. I have the add in created and it works when i transfer to other computers. Now i want to make a custom ribbon. I can't figure out how to activate a macro with a button. Running the macro using the developer tab, has no error. assigning the macro to a button on the "QAT" works also. I am using the "Custom UI Editor" to create the Ribbon, everything "works" until it gets to the macro. "Wrong number of arguments or invalid property assignment" appears. I may have to change something in the code, but being a NOOB, i can't figure it out.



    XML code for ribbon
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    	<ribbon>
    		<tabs>
    			<tab id="customTab" label="S-Macro" insertAfterMso="TabHome">
    				<group id="customGroup" label="Scott's Macros">
    					<button id="customButton1" label="Copy Row" size="large" onAction="Personal.xlsm.AddNewRowButton" imageMso="EndOfDocument" />
    				</group>
    				<group idMso="GroupEnterDataAlignment" />
    				<group idMso="GroupEnterDataNumber" />
    				<group idMso="GroupQuickFormatting" />
    			</tab>
    		</tabs>
    	</ribbon>
    </customUI>
    This is the recorded Macro Code for: Module1
    Sub AddNewRowButton()
    '
    ' AddNewRowButton Macro
    '
    
    '
        ActiveSheet.Buttons.Add(0, 0, 240.75, 30.75).Select
        Selection.OnAction = "InsertRowsAndFillFormulas_caller"
        With Selection.Font
            .Name = "Times New Roman"
            .FontStyle = "Regular"
            .Size = 8
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
        End With
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlTop
            .ReadingOrder = xlContext
            .Orientation = xlHorizontal
            .AutoSize = False
        End With
        Selection.Characters.text = _
            "Select the row above where you want to insert the rows, this is also the row whose formulas will be copied down. Then press Button."
        With Selection.Characters(Start:=1, Length:=131).Font
            .Name = "Times New Roman"
            .FontStyle = "Regular"
            .Size = 8
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = 1
        End With
        Range("D7").Select
    End Sub

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Customize Ribbon Code. Need Help!

    the callback you specify for the onAction parameter needs a specific declaration. change the first line of code to
    Sub AddNewRowButton(control as IRibbonControl)
    note that the customui editor has a button to generate the callback procedure stubs for you
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    10-25-2012
    Location
    Ne/Ia
    MS-Off Ver
    office 2016
    Posts
    52

    Re: Customize Ribbon Code. Need Help!

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1