Simulate click of AutoSum doesn't work in 2007

X

XP

In the past I have used the following code line to simulate a click of the
"AutoSum" button.

Application.CommandBars("Standard").Controls("&AutoSum").Execute

This doesn't work in 2007; recording the macro doesn't work either. Anyone
have an equivalent that works in 2007; if so could you please post?

Thanks in advance for your assistance.
 
J

Jim Rech

This vintage code still seems to work in Excel 2007.

Sub DoAutoSum()
Dim x As CommandBarControl
Set x = CommandBars.FindControl(ID:=226)
Set x = x.Controls(1)
x.Execute 'AutoSum
If Selection.Cells.Count = 1 Then
x.Execute 'Again to exit edit mode
End If
End Sub

--
Jim
| In the past I have used the following code line to simulate a click of the
| "AutoSum" button.
|
| Application.CommandBars("Standard").Controls("&AutoSum").Execute
|
| This doesn't work in 2007; recording the macro doesn't work either. Anyone
| have an equivalent that works in 2007; if so could you please post?
|
| Thanks in advance for your assistance.
 
R

Ron de Bruin

Hi Jim

I try this first but it blow
Application.CommandBars.FindControl(ID:=226).Execute

So posted this
Application.CommandBars.ExecuteMso ("AutoSum")

But yours is working OK
 
J

Jim Rech

Totally forgot about ExecuteMso, Ron. Thanks.

--
Jim
| Hi Jim
|
| I try this first but it blow
| Application.CommandBars.FindControl(ID:=226).Execute
|
| So posted this
| Application.CommandBars.ExecuteMso ("AutoSum")
|
| But yours is working OK
|
|
| --
|
| Regards Ron de Bruin
| http://www.rondebruin.nl/tips.htm
|
|
| > This vintage code still seems to work in Excel 2007.
| >
| > Sub DoAutoSum()
| > Dim x As CommandBarControl
| > Set x = CommandBars.FindControl(ID:=226)
| > Set x = x.Controls(1)
| > x.Execute 'AutoSum
| > If Selection.Cells.Count = 1 Then
| > x.Execute 'Again to exit edit mode
| > End If
| > End Sub
| >
| > --
| > Jim
| > | > | In the past I have used the following code line to simulate a click of
the
| > | "AutoSum" button.
| > |
| > | Application.CommandBars("Standard").Controls("&AutoSum").Execute
| > |
| > | This doesn't work in 2007; recording the macro doesn't work either.
Anyone
| > | have an equivalent that works in 2007; if so could you please post?
| > |
| > | Thanks in advance for your assistance.
| >
 
R

Ron de Bruin

Hi Jim

Is my answer in this thread "Selective Ribbon miminise" correct
or is there a better way ?

I never wanted to keep the QAT and hide the Ribbon myself so this was my first thought.
 
J

Jim Rech

What you posted is the only way I know of to HIDE the ribbon and leave the
QAT.

But he didn't ask that. He wanted (1) a macro to (2) "disable" the ribbon
and (3) leave the QAT so he can use it for his toolbar.

So I think the answer to his question is "it can't be done".<g>

--
Jim
| Hi Jim
|
| Is my answer in this thread "Selective Ribbon miminise" correct
| or is there a better way ?
|
| I never wanted to keep the QAT and hide the Ribbon myself so this was my
first thought.
|
|
| --
|
| Regards Ron de Bruin
| http://www.rondebruin.nl/tips.htm
|
|
| > Totally forgot about ExecuteMso, Ron. Thanks.
| >
| > --
| > Jim
| > | > | Hi Jim
| > |
| > | I try this first but it blow
| > | Application.CommandBars.FindControl(ID:=226).Execute
| > |
| > | So posted this
| > | Application.CommandBars.ExecuteMso ("AutoSum")
| > |
| > | But yours is working OK
| > |
| > |
| > | --
| > |
| > | Regards Ron de Bruin
| > | http://www.rondebruin.nl/tips.htm
| > |
| > |
| > | > | > This vintage code still seems to work in Excel 2007.
| > | >
| > | > Sub DoAutoSum()
| > | > Dim x As CommandBarControl
| > | > Set x = CommandBars.FindControl(ID:=226)
| > | > Set x = x.Controls(1)
| > | > x.Execute 'AutoSum
| > | > If Selection.Cells.Count = 1 Then
| > | > x.Execute 'Again to exit edit mode
| > | > End If
| > | > End Sub
| > | >
| > | > --
| > | > Jim
| > | > | > | > | In the past I have used the following code line to simulate a
click of
| > the
| > | > | "AutoSum" button.
| > | > |
| > | > | Application.CommandBars("Standard").Controls("&AutoSum").Execute
| > | > |
| > | > | This doesn't work in 2007; recording the macro doesn't work
either.
| > Anyone
| > | > | have an equivalent that works in 2007; if so could you please
post?
| > | > |
| > | > | Thanks in advance for your assistance.
| > | >
| >
 
R

Ron de Bruin

Hi Jim

OK you are right but he can use the buttons he add to the QAT for only that workbook.
It looks like a toolbar then <g>

Have a nice weekend
 

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