Shortcut code VBA not working

rob_sheeds

Board Regular
Joined
Dec 9, 2010
Messages
57
I have saved this and another sub in my personal workbook, but it wont run when I press Ctrl + Shift + e
Can anyone please help

Public Sub Open_Unprotect_SaveAs()
Application.OnKey "^+e", "Unprotect_SaveAs()"
End Sub

Public Sub Unprotect_SaveAs()
'
' Unprotect and Save as .xls Macro
Dim MyString As String
ActiveSheet.Unprotect
ActiveWorkbook.Unprotect
MyString = Range("C4") & " " & Range("C5") & " " & Range("D4")
FileDrive = "R:\EOM GL Reporting\Franchising\P&L's to be uploaded\2012\29082011"
ActiveWorkbook.SaveAs Filename:=MyString, FileFormat:=56
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hello,

I see you are using onkey.

Have you tried to do this natively?

Try this:



Alt + F8 to open the macro dialog
Select your macro
then click the Options button

There you can specify a shortcut key (hold shift and press E).

Does that make any difference?

-Jeff
 
Upvote 0
Thanks Jeff, I did that and it works, though it isnt saving in the directory. It is getting the file name correct and then asks me to save over the file, but the file doesnt exist both before or after. I have checked the directory, even copied the directory into window explorer and still nothing?
 
Upvote 0
Ok worked it out, and an issue with password. Thanks again jeff.

Public Sub Unprotect_SaveAs()
'
' Unprotect and Save as .xls Macro
Dim MyString As String
Worksheets("Data Input").Activate
ActiveSheet.Unprotect Password:="sg6228"
ActiveWorkbook.Unprotect Password:="sg6228"
Worksheets("Data Input").Activate
MyString = Range("C4") & " " & Range("C5") & " " & Range("D4")
FileDrive = "R:\EOM GL Reporting\Franchising\P&L's to be uploaded\2012\29082011\"
ActiveWorkbook.SaveAs Filename:=FileDrive & MyString, FileFormat:=56
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,153
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top