I
is
I'm trying to add a keyboard shortcut for a function I have. I have the
following code in the "ThisWorkbook" 'module':
Option Explicit
Const DATECOL As String = "B"
Public Sub FindToday()
' Keyboard Shortcut: Ctrl+T
Dim r As Range
On Error Resume Next
Set r = ThisWorkbook.Worksheets(1).Range(DATECOL & ":" &
DATECOL).Find(what:=Date, LookIn:=xlValues)
If Not r Is Nothing Then
r.Select
End If
ThisWorkbook.Sheets(1).Activate
End Sub
Public Sub Workbook_Open()
Application.MacroOptions Macro:="FindToday", HasShortcutKey:=True,
ShortcutKey:="t"
FindToday
End Sub
I get:Run-time error "1004":
Method 'MacroOptions' of object '_Application' failed
<<
I've tried all sorts of things (making the routines public, trying
Macro:=ThisWorkbook.Name & "!" & "FindToday", trying it without
assigning the shortcut key - all fail.
Any suggestions, please?!
following code in the "ThisWorkbook" 'module':
Option Explicit
Const DATECOL As String = "B"
Public Sub FindToday()
' Keyboard Shortcut: Ctrl+T
Dim r As Range
On Error Resume Next
Set r = ThisWorkbook.Worksheets(1).Range(DATECOL & ":" &
DATECOL).Find(what:=Date, LookIn:=xlValues)
If Not r Is Nothing Then
r.Select
End If
ThisWorkbook.Sheets(1).Activate
End Sub
Public Sub Workbook_Open()
Application.MacroOptions Macro:="FindToday", HasShortcutKey:=True,
ShortcutKey:="t"
FindToday
End Sub
I get:Run-time error "1004":
Method 'MacroOptions' of object '_Application' failed
<<
I've tried all sorts of things (making the routines public, trying
Macro:=ThisWorkbook.Name & "!" & "FindToday", trying it without
assigning the shortcut key - all fail.
Any suggestions, please?!