I tried to record undo and redo using Excel 2007 with no such luck.
I'm trying to find these codes so that I can attch to a custom tool bar i'm designing
Code to Undo and Redo
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
-
- Administrator
- Posts: 80384
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Code to Undo and Redo
There is no point in using Undo and Redo from code - running VBA code clears the undo/redo stack. But Excel has built-in undo and redo buttons; they have ID 128 and 129, respectively. So you could use code like this:
Dim cbb As CommandBarControl
Set cbb = CommandBars("Test").Controls.Add(msoControlSplitDropdown, 128, , , True)
Dim cbb As CommandBarControl
Set cbb = CommandBars("Test").Controls.Add(msoControlSplitDropdown, 128, , , True)
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Code to Undo and Redo
Hi HansV
I tried 128 and 129 and recieved the same error
I tried 128 and 129 and recieved the same error
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 80384
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Code to Undo and Redo
Obviously, the code I posted was just an example. You should replace CommandBars("Test") with a reference to the custom toolbar that you're creating.
But why do you need this at all? Undo and Redo are already available on the Standard toolbar in Excel 2003 and before, and on the Quick Access Toolbar in Excel 2007 and later.
But why do you need this at all? Undo and Redo are already available on the Standard toolbar in Excel 2003 and before, and on the Quick Access Toolbar in Excel 2007 and later.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Code to Undo and Redo
Thank you HansV
I will make the changes you suggested.
I’m designing a single tool bar that will have all the needed and basic tools in a single location.
It makes it more user friendly for a beginner.
Here is how it looks so far.
I will make the changes you suggested.
I’m designing a single tool bar that will have all the needed and basic tools in a single location.
It makes it more user friendly for a beginner.
Here is how it looks so far.
You do not have the required permissions to view the files attached to this post.
-
- 5StarLounger
- Posts: 826
- Joined: 24 Jan 2010, 15:56
Re: Code to Undo and Redo
Why not just add the actual Undo and Redo galleries to your tab?
Regards,
Rory
Rory
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Code to Undo and Redo
Hi rory
Are you referring to the Quick Access Toolbar?
Are you referring to the Quick Access Toolbar?
-
- 5StarLounger
- Posts: 826
- Joined: 24 Jan 2010, 15:56
Re: Code to Undo and Redo
No, to your tab. Since you are using XML anyway, you might as well.
Regards,
Rory
Rory
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Code to Undo and Redo
Hi rory
That is what I was hoping for; all I needed was to get the code. HansV provided that I just haven’t tried it yet.
That is what I was hoping for; all I needed was to get the code. HansV provided that I just haven’t tried it yet.
-
- 5StarLounger
- Posts: 826
- Joined: 24 Jan 2010, 15:56
Re: Code to Undo and Redo
My point is that if you use the built-in controls, you don't need any code at all - they just work! :)
All you need in your CustomUI is:
<control idMso="Undo" size="large" />
<control idMso="Redo" size="large" />
All you need in your CustomUI is:
<control idMso="Undo" size="large" />
<control idMso="Redo" size="large" />
Regards,
Rory
Rory
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Code to Undo and Redo
Hi rory
Very cool I didnt know I could add controls to ribbon this way.
let me give it a try
Thank you
Very cool I didnt know I could add controls to ribbon this way.
let me give it a try
Thank you
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Code to Undo and Redo
Hi rory
It worked perfect, thank you
It worked perfect, thank you
You do not have the required permissions to view the files attached to this post.