KentBurel
Board Regular
- Joined
- Mar 27, 2020
- Messages
- 68
- Office Version
- 2019
- Platform
- Windows
I have a userform that contains a text box that provides information for the first page in my workbook. I want this displayed when the workbook is first opened but only the first time. If the user wants to see the instructions again then he/she can press the F1 key. This all works until the F1 key is pressed and then I get this error message:
Here are my macros that set this up:
The Constants sheet is the first sheet in the workbook. The Constants sheet contains this code:
The ThisWorkBook module contains this code:
DisplayConstantsHelp is the name of the userform. I used this technique before to map the F1 key to a userform only when a particular sheet is displayed. Now it's giving me a strange error.
Thanks for your help.
Here are my macros that set this up:
The Constants sheet is the first sheet in the workbook. The Constants sheet contains this code:
VBA Code:
Option Explicit
Private Sub Worksheet_Deactivate()
Application.OnKey "{F1}"
DisplayConstantsHelp.Hide
End Sub
Private Sub Worksheet_Activate()
Application.OnKey "{F1}", "DisplayConstantsHelp.Show"
End Sub
The ThisWorkBook module contains this code:
VBA Code:
Sub Workbook_open()
DisplayConstantsHelp.Show
End Sub
DisplayConstantsHelp is the name of the userform. I used this technique before to map the F1 key to a userform only when a particular sheet is displayed. Now it's giving me a strange error.
Thanks for your help.