Excel procedure works in VBA but not from the Ribbon???

J

JeremyJ

I get this "Incorrect Function" error and I have narrowed the problem down to
it being only 2 lines of VBA code.

Sub xyz()
ActiveWorkbook.Save
End
End Sub

I need the "End" line of code to clear all variables (there are hundreds of
them). When I run this straight from VBA there are no problems but when I run
the procedure from a ribbon button the "Incorrect Function" error pops up.

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="MyCustomTab" label="My Tab" insertAfterMso="TabHome">
<group id="customGroup1" label="Group 1">
<button id="customButton1" label="Button 1" size="normal"
onAction="xyz" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>

Sub xyz(control As IRibbonControl)
ActiveWorkbook.Save
End
End Sub

The code runs find when either one is absent but not when they run together.

Is there a fix to this problem?
or
Is there another way I can clear all variables with out typing "X=Empty" for
each one?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top