sassriverrat
Well-known Member
- Joined
- Oct 4, 2018
- Messages
- 655
Good Morning,
I keep fighting this VBA refocus issue and I haven't been able to get it to work. Below is a section of code from a userform. The userform opens up with a button that shows the "administration" page in the workbook (i.e. a hidden page). Anyway, if I open any excel sheet before I open this workbook, this workbook will open correctly but when this userform unloads, the other workbook(s) will always be on top, i.e. the focus. I have to manually click this workbook to get the focus back on it.
A few things to note: This workbook, upon its opening code, is designed to hide the application (excel) and go straight into the userform. The user can click the button (code below) to get into the workbook. This same issue arises no matter which button (1, 2, or 3) I click on the userform. Below is just one of the buttons.
Thanks
I keep fighting this VBA refocus issue and I haven't been able to get it to work. Below is a section of code from a userform. The userform opens up with a button that shows the "administration" page in the workbook (i.e. a hidden page). Anyway, if I open any excel sheet before I open this workbook, this workbook will open correctly but when this userform unloads, the other workbook(s) will always be on top, i.e. the focus. I have to manually click this workbook to get the focus back on it.
A few things to note: This workbook, upon its opening code, is designed to hide the application (excel) and go straight into the userform. The user can click the button (code below) to get into the workbook. This same issue arises no matter which button (1, 2, or 3) I click on the userform. Below is just one of the buttons.
Thanks
Code:
Private Sub CommandButton3_Click()
On Error GoTo Helper
Dim name As String
name = ThisWorkbook.Sheets("Notes").Range("N4")
Sheet13.Activate
TryAgain:
Pass = InputBox("Enter Password", "The Coding Sheets")
If Pass = "" Then Exit Sub
If Pass = CStr(Worksheets("Developer").Range("B23").Value) Then
Sheets("Developer").Visible = True
Sheets("Notes").Visible = True
Sheets("Ports").Visible = True
Sheets("Developer").Select
Application.Visible = True
ThisWorkbook.Activate
Else
MsgBox "Password incorrect, Please try again", vbCritical, name
GoTo TryAgain
End If
Unload Me
ThisWorkbook.Activate
Exit Sub[\code]