F
Ferg
Hi,
Can someone please help me out with this - it's been driving me nuts for
months...
I have a Workbook_Open macro in Excel 97 that calls two other macros as
follows:
************************************************************
Private Sub Workbook_Open()
Stop
MacroOnKeySetUP
PacLogSetup
End Sub
Sub MacroOnKeySetUP()
'
'Sets the "MacroCaller to run when either "Enter" Key is hit
'
Dim Counter As Integer, TotalColumns As Integer
Application.OnKey "{Enter}", "MacroCallerEnter"
Application.OnKey "~", "MacroCallerEnter"
Application.OnKey "{TAB}", "MacroCallerTAB"
Application.OnKey "{Down}", "MacroCallerDown"
Application.OnKey "{Up}", "MacroCallerUp"
Application.OnKey "{Left}", "MacroCallerLeft"
Application.OnKey "{Right}", "MacroCallerRight"
Sheets("PAC LOG").Activate
ActiveSheet.AutoFilterMode = False
Selection.AutoFilter
Range("A65536").End(xlUp).Offset(1, 0).Activate
End Sub
Sub PacLogSetup()
Dim MsgResponse As Integer, RejectFound As Boolean
Application.ScreenUpdating = False
'Check for Status = "Rejected"
RejectFound = False
On Error Resume Next
RejectFound = Columns("C").Find(What:="Rejected", After:=Range("C5"),
LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
On Error GoTo 0
If RejectFound Then
MsgResponse = MsgBox("Welcome to Pac_Log.xls" & Chr(10) & Chr(10) & _
"Do you wish to review the outstanding Rejected PACs?" &
Chr(10) & Chr(10) & _
"(NOTE: Click the 'Setup Macro' button to return to normal
display.)", _
vbYesNo + vbQuestion, "Pac_Log.xls")
If MsgResponse = vbYes Then
Selection.AutoFilter Field:=3, Criteria1:="Rejected"
ActiveWindow.ScrollRow = 6 'Scroll to show Row 6 at the top of
the pane
Cells(ActiveCell.Row, 1).Select
Else 'User clicked on "No"
Range("A65536").End(xlUp).Offset(1, 0).Activate
End If
Else 'No PACs with Status = Rejected.
MsgBox "Welcome to Pac_Log.xls" & Chr(10) & Chr(10) & _
"There are no outstanding Rejected PACs." & Chr(10) &
Chr(10) & _
"(NOTE: Click the 'Setup Macro' button ensure Pac_Log.xls
operates properly.)", _
vbOKOnly + vbInformation, "Pac_Log.xls"
Range("A65536").End(xlUp).Offset(1, 0).Activate
End If
Application.ScreenUpdating = True
End Sub
************************************************************
When I open the spreadsheet from Windows Explorer, everything works
perfectly and I get the expected results. But, when I open the file from
within Excel (either by selecting File - Open, or from the Recently Used File
List, or via a custom Tool bar item), the code runs, but the OnKey statements
don't work, and the Find fails (even though I know there is matching data in
the spreadsheet).
Can anyone shed light on why this is happenning?
Can someone please help me out with this - it's been driving me nuts for
months...
I have a Workbook_Open macro in Excel 97 that calls two other macros as
follows:
************************************************************
Private Sub Workbook_Open()
Stop
MacroOnKeySetUP
PacLogSetup
End Sub
Sub MacroOnKeySetUP()
'
'Sets the "MacroCaller to run when either "Enter" Key is hit
'
Dim Counter As Integer, TotalColumns As Integer
Application.OnKey "{Enter}", "MacroCallerEnter"
Application.OnKey "~", "MacroCallerEnter"
Application.OnKey "{TAB}", "MacroCallerTAB"
Application.OnKey "{Down}", "MacroCallerDown"
Application.OnKey "{Up}", "MacroCallerUp"
Application.OnKey "{Left}", "MacroCallerLeft"
Application.OnKey "{Right}", "MacroCallerRight"
Sheets("PAC LOG").Activate
ActiveSheet.AutoFilterMode = False
Selection.AutoFilter
Range("A65536").End(xlUp).Offset(1, 0).Activate
End Sub
Sub PacLogSetup()
Dim MsgResponse As Integer, RejectFound As Boolean
Application.ScreenUpdating = False
'Check for Status = "Rejected"
RejectFound = False
On Error Resume Next
RejectFound = Columns("C").Find(What:="Rejected", After:=Range("C5"),
LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
On Error GoTo 0
If RejectFound Then
MsgResponse = MsgBox("Welcome to Pac_Log.xls" & Chr(10) & Chr(10) & _
"Do you wish to review the outstanding Rejected PACs?" &
Chr(10) & Chr(10) & _
"(NOTE: Click the 'Setup Macro' button to return to normal
display.)", _
vbYesNo + vbQuestion, "Pac_Log.xls")
If MsgResponse = vbYes Then
Selection.AutoFilter Field:=3, Criteria1:="Rejected"
ActiveWindow.ScrollRow = 6 'Scroll to show Row 6 at the top of
the pane
Cells(ActiveCell.Row, 1).Select
Else 'User clicked on "No"
Range("A65536").End(xlUp).Offset(1, 0).Activate
End If
Else 'No PACs with Status = Rejected.
MsgBox "Welcome to Pac_Log.xls" & Chr(10) & Chr(10) & _
"There are no outstanding Rejected PACs." & Chr(10) &
Chr(10) & _
"(NOTE: Click the 'Setup Macro' button ensure Pac_Log.xls
operates properly.)", _
vbOKOnly + vbInformation, "Pac_Log.xls"
Range("A65536").End(xlUp).Offset(1, 0).Activate
End If
Application.ScreenUpdating = True
End Sub
************************************************************
When I open the spreadsheet from Windows Explorer, everything works
perfectly and I get the expected results. But, when I open the file from
within Excel (either by selecting File - Open, or from the Recently Used File
List, or via a custom Tool bar item), the code runs, but the OnKey statements
don't work, and the Find fails (even though I know there is matching data in
the spreadsheet).
Can anyone shed light on why this is happenning?