Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not working code in Custom UI editor 1

Status
Not open for further replies.

wmbb

Technical User
Jul 17, 2005
320
NL
I've created a Tab and group with a button in WORD 2007 using the custom UI editor and the code below trying to start the macro "endmarker" ...

Code:
<customUI xmlns="[URL unfurl="true"]http://schemas.microsoft.com/office/2006/01/customui">[/URL]
	<ribbon startFromScratch="false">
		<tabs>
			<tab id="customTab" label="Custom">
				<group id="Group" label="Group">
					<button id="customButton" label="end" image="end" size="large" onAction="Module1.endmarker" />
				</group>
			</tab>
		</tabs>
	</ribbon>
</customUI>

Clicking the button an error appears:
"wrong number of arguments or invalid property assignment"

Running the macro directly in WORD there is no problem !
 
What happens when you remove the "Module1."?

Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
How have you declared the "endmarker" Sub? It should be something like ..

Code:
[blue]Public Sub endmarker(RibbonControl As IRibbonControl)[/blue]

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
GlennUK:
Yes but that results in the same error

TonyJollans:
No I haven't. This is my first attempt to customize the UI.
Where do I have to declare the sub "endmarker" ?
I've created the macro in Module1 ?
 
In your xml you have [blue]onAction="Module1.endmarker"[/blue], which means you need to have a macro called endmarker in module Module1, defined as I posted before. When you say you have created the macro, what, exactly do you have so far?

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
First thanks for your quick response en willing to help.

I have a document called test.dotm with a module1 attached in the VB editor containing the macro "endmarker" for the time being just a simple macro:

Code:
Sub endmarker()
'
' test endmarker Macro
'
    Selection.EndKey Unit:=wdStory
    Selection.TypeParagraph
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.TypeText Text:="--o--o--o--"

End Sub

Beside that I created for document test.dotm a Tab, a Group and a button in the ribbon of WORD2007 using the custom UI editor and the code below trying to start the macro "endmarker" with the created button.
Code in UI editor:
Code:
<customUI xmlns="[URL unfurl="true"]http://schemas.microsoft.com/office/2006/01/customui">[/URL]
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="customTab" label="Custom">
                <group id="Group" label="Group">
                    <button id="customButton" label="end" image="end" size="large" onAction="Module1.endmarker" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

I get the error message by opening the template enabling the macro's and clicking the button created.

If you need more information please let me know.
I've attached the document to this reply.
 

Problem solved !!!
I've replaced "Sub endmarker()" with "Public Sub endmarker(RibbonControl As IRibbonControl)" and it works.
Thanks for your help !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top