Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
I have the following script to put in sheet not module. The marco works when I run by press ATL F8 but not the shortcut (received error). How can I modify it to make it to run with shortcut key as well.
Sub CreateShortcutMsg ()
Application.OnKey "^{98}", OpenOutlookTemplate"
End Sub
Sub DeleteShortcutMsg ()
Application.OnKey "^{98}", OpenOutlookTemplate"
End Sub
Sub OpenOutlookTemplate()
If ActiveWorkbook Is ThisWorkbook Then
Dim myoutapp As Object
Dim myitem As Object
Set myoutapp = CreateObject("Outlook.Application")
Set myitem = myoutapp.CreateItemFromTemplate("C:\Users\vincentszeto\Desktop\MrExcel.msg")
myitem.Display
End If
End Sub
Error when press the shortcut key
Sub CreateShortcutMsg ()
Application.OnKey "^{98}", OpenOutlookTemplate"
End Sub
Sub DeleteShortcutMsg ()
Application.OnKey "^{98}", OpenOutlookTemplate"
End Sub
Sub OpenOutlookTemplate()
If ActiveWorkbook Is ThisWorkbook Then
Dim myoutapp As Object
Dim myitem As Object
Set myoutapp = CreateObject("Outlook.Application")
Set myitem = myoutapp.CreateItemFromTemplate("C:\Users\vincentszeto\Desktop\MrExcel.msg")
myitem.Display
End If
End Sub
Error when press the shortcut key