Excel 2010 - VBA code to disable undo command for a workbook

I am using excel 2010 and I need to find a way to disable the undo command when I open a certain workbook.  Everything I am able to find right now is for earlier versions of excel and I read somewhere and learned from my own attempts that I need a completely different approach for this in excel 2010.  I was thinking of disabling / enabling the command based on the workbook's activate / deactivate events.

Thanks for your help.
Matt JohnsonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
[ fanpages ]IT Services ConsultantCommented:
Hi,

Are you able to update the Windows Registry within the run-time environment?

Although not stated explicitly within the following article, you can adjust the number of undo available within the Workbook_Open() event code, & restore within the Workbook_BeforeClose() event code, or the Activate/Deactive events as you suggested:

"How to modify the number of undo levels in Excel"
[ http://support.microsoft.com/?kbid=211922 ]

Simply use the "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Options" key for Microsoft Excel 2010.

---
By default, Excel allocates RAM for 16 undo levels. The registry setting that is described in this article lets you change the default value to a value that you specify.

If the undo history is set to zero, no memory is allocated for undoing actions. The higher the undo history value, the more memory Excel allocates for the history. This directly affects the performance of your computer when you run Excel.

Note When you run a Visual Basic for Applications macro, Excel allocates no memory for undoing actions. This feature is disabled for optimization of performance when you run a macro.

To use Registry Editor to change the number of undo levels, follow these steps.

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows

    Close any programs that are running.
    Click Start, click Run, type regedit in the Open box, and then click OK.
    In Registry Editor, expand one of the following registry subkeys, as appropriate for the version of Excel that you are running:

    Microsoft Office Excel 2007
    HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Options
    Microsoft Office Excel 2003
    HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Options
    Microsoft Excel 2002
    HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Excel\Options
    Microsoft Excel 2000
    HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Excel\Options
    On the Edit menu, point to New, and then click DWORD Value. Select New Value #1, type UndoHistory, and then press ENTER.
    On the Edit menu, click Modify.
    In the Edit DWORD Value dialog box, click Decimal under Base. Type a value between 0 and 100 in the Value box, click OK, and then exit Registry Editor.
    Start Excel. Excel stores an undo history for the number of actions that you specified in step 6.
---

BFN,

fp.
0
 
Alexander Eßer [Alex140181]Software DeveloperCommented:
You can start here (for enabling/disabling hot keys and toolbars), maybe it helps:

http://www.rondebruin.nl/win/s4/win011.htm

http://www.rondebruin.nl/win/s5/win005.htm

http://www.rondebruin.nl/win/section6.htm
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
[ fanpages ]IT Services ConsultantCommented:
you can adjust the number of undo available
Please read as...
you can adjust the number of undo levels available
:)
0
 
Alexander Eßer [Alex140181]Software DeveloperCommented:
By the way: IT'S A VERY VERY BAD IDEA TO TOUCH THE REGISTRY IN ORDER TO GET THINGS DONE ;-)
It's just a messy workaround :-( = (very) bad paractice
0
 
[ fanpages ]IT Services ConsultantCommented:
By the way: IT'S A VERY VERY BAD IDEA TO TOUCH THE REGISTRY IN ORDER TO GET THINGS DONE ;-)
It's just a messy workaround :-( = (very) bad paractice

It is not "messy" at all.  It is the most efficient method of meeting your needs.

The configurable settings are there for the purpose of changing them to suit your environment's requirements.

If you are careful, & follow the advice/instructions provided by Microsoft, then there is minimal risk.
0
 
Alexander Eßer [Alex140181]Software DeveloperCommented:
I have NEVER seen anyone writing efficient AND good code (in terms of SW design and SW patterns) at the same time through manipulating the registry...
Nevertheless, in the end it's up to mattej1 to choose the "right" solution which suites him best ;-)
0
 
[ fanpages ]IT Services ConsultantCommented:
I have NEVER seen anyone writing efficient AND good code (in terms of SW design and SW patterns) at the same time through manipulating the registry...

You're new here.
0
 
Alexander Eßer [Alex140181]Software DeveloperCommented:
You're new here.

So what?!
0
 
[ fanpages ]IT Services ConsultantCommented:
So what?!
If you were not a new member, then you may have seen some of my previous contributions that use the registry settings for tasks that are far from easy (if not impossible) using coded solutions.

For example, "URGENT- Auto enabling the Macros" (October 2003)

[ http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_20753813.html ]

Also, "Importing Excel Spreadsheet into Access 20[0]3" (October 2005)

[ http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_21598125.html#a15160522 ]

Registry settings are there to be used, otherwise why would they be there at all?

I am sorry you are not as familiar with their usage & their possibilities, but that does not make them inefficient or detrimental to good coding techniques.  They can co-exist, &/or complement such techniques.
0
 
[ fanpages ]IT Services ConsultantCommented:
You're welcome,  mattej1.

(Sigh)
0
All Courses

From novice to tech pro — start learning today.