Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application.OnKey - Store Procedure?

Status
Not open for further replies.

clouddog9

Technical User
Jul 31, 2009
55
US
Is there a way to store the current Procedure on an OnKey?

Example:

If you open up workbook "A" this is the code in the ThisWorkbook Object:
Code:
Private Sub Workbook_Open()
    With Application
        .DisplayAlerts = False
        .OnKey "^{g}", "'" & ThisWorkbook.Name & "'!Password_Macros.Unprotect"
        .OnKey "^+{t}", "'" & ThisWorkbook.Name & "'!Password_Macros.Protect"
    End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    With Application
        .OnKey "^{g}"
        .OnKey "^+{t}"
        .DisplayAlerts = True
    End With
End Sub

As you can tell if the workbook is closed the OnKeys get reset to their default. Is there a way to store what ever was on the onkey procedure prior to assigning it a new procedure then assigning it back when the workbook is closed?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top