P
Paul Moles
I have the following code in ThisWorkbook module of Personal.xls:
Private Sub Workbook_Open()
'Sub Autpen ()
Dim NewControl As CommandBarControl
' Assign shortcut to Insert Today on SHIFT+CTRL+D
Application.OnKey "+^{D}", "Module2.Insert_Date"
' Add item to shortcut menu on open
On Error Resume Next
Application.CommandBars("Cell").Controls("Insert Date").Delete
On Error GoTo 0
Set NewControl = Application.CommandBars("Cell").Controls.Add
With NewControl
.Caption = "Insert Date"
.OnAction = "Module2.Insert_Date"
.BeginGroup = True
End With
' Assign shortcut to display Calendar Date on SHIFT+CTRL+C
Application.OnKey "+^{C}", "Module11.OpenCalendar"
' Add item to shortcut menu on open
On Error Resume Next
Application.CommandBars("Cell").Controls("Calendar Date").Delete
On Error GoTo 0
Set NewControl = Application.CommandBars("Cell").Controls.Add
With NewControl
.Caption = "Calendar Date"
.OnAction = "Module11.OpenCalendar"
.BeginGroup = False
End With
End Sub
Adapted from Martin Green web page www.fontstuff.com, however it doesn't
seem to matter whether it is Private Sub Workbook_Open() or Sub Autpen ()
it doesn't run when Excel starts up.
However in either case if I Run Sub/UserForm from within VBE it works quite
happily.
Personal.xls appears to be loading Ok as it is visible in the VBE and I can
run other macros that are contained with it from Tools, Macros.
There are no other Autpen or Workbook_Open modules.
I have tried putting Sub Autpen() as a module but still no luck
Any Suggestions?
Many Thanks
Private Sub Workbook_Open()
'Sub Autpen ()
Dim NewControl As CommandBarControl
' Assign shortcut to Insert Today on SHIFT+CTRL+D
Application.OnKey "+^{D}", "Module2.Insert_Date"
' Add item to shortcut menu on open
On Error Resume Next
Application.CommandBars("Cell").Controls("Insert Date").Delete
On Error GoTo 0
Set NewControl = Application.CommandBars("Cell").Controls.Add
With NewControl
.Caption = "Insert Date"
.OnAction = "Module2.Insert_Date"
.BeginGroup = True
End With
' Assign shortcut to display Calendar Date on SHIFT+CTRL+C
Application.OnKey "+^{C}", "Module11.OpenCalendar"
' Add item to shortcut menu on open
On Error Resume Next
Application.CommandBars("Cell").Controls("Calendar Date").Delete
On Error GoTo 0
Set NewControl = Application.CommandBars("Cell").Controls.Add
With NewControl
.Caption = "Calendar Date"
.OnAction = "Module11.OpenCalendar"
.BeginGroup = False
End With
End Sub
Adapted from Martin Green web page www.fontstuff.com, however it doesn't
seem to matter whether it is Private Sub Workbook_Open() or Sub Autpen ()
it doesn't run when Excel starts up.
However in either case if I Run Sub/UserForm from within VBE it works quite
happily.
Personal.xls appears to be loading Ok as it is visible in the VBE and I can
run other macros that are contained with it from Tools, Macros.
There are no other Autpen or Workbook_Open modules.
I have tried putting Sub Autpen() as a module but still no luck
Any Suggestions?
Many Thanks