Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Procedure works from VBA but not the Ribbon

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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Procedure works from VBA but not the Ribbon

Hi JeremyJ

You must use it like this

'Callback for xyz onAction
Sub xyz(control as IRibbonControl)

End Sub


There is button in the UI editor that you can use

Generate Callbacks : This will create macros(callbacks) for each onAction you have in
the RibbonX. Select all callbacks and copy them in a normal module in your workbook.


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"JeremyJ" wrote in message ...
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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Procedure works from VBA but not the Ribbon

If you have two subs with the same name you're asking for trouble. Surely
you can rename one.

--
Jim
"JeremyJ" wrote in message
...
|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?
|

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle button - procedure works but elegance needed (xl2007) Kragelund Excel Programming 4 October 25th 08 09:22 PM
UNIQ EXPEREINCE: PROCEDURE WORKS FINE USING F8 BUT GET ERROR WHEN COMMAND BUTTON IS CLICKED CAPTGNVR Excel Programming 1 July 6th 07 10:32 PM
How to jump from a Form procedure to a Workbook or Module procedure? T. Erkson Excel Programming 4 January 25th 07 07:15 PM
defining an event procedure (lostfocus) that works on a column range juhlott Excel Programming 1 July 8th 04 08:26 PM


All times are GMT +1. The time now is 11:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"