I have code that displays a worksheet that tells the user to turn on macros, with other sheets being kept hidden. Once the workbook is re-opened, the remaining worksheets are displayed and the sheet that tells the user to turn on macros is hidden.
I want to display a userform before displaying the hidden worksheets.
Option Explicit
Const origsave As String = "C:\SDK Engineering\iMudCalc Software"
Const origwrkbksave As String = "C:\SDK Engineering\iMudCalc Software\iMudCalc.xlsm"
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
'don't display workbook
Application.Visible = False
'Unhide the Starting Sheet
Sheets("Warning").Visible = xlSheetVisible
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Warning" Then
ws.Visible = xlVeryHidden
End If
Next ws
If Len(Dir(origsave)) > 0 Then
MkDir (origsave)
Else
ActiveWorkbook.SaveCopyAs (origwrkbksave)
End If
End Sub
Private Sub WorkBook_Open()
Dim ws As Worksheet
Application.Visible = False
For Each ws In ThisWorkbook.Worksheets
ws.Visible = xlSheetVisible
Next ws
Sheets("Warning").Visible = xlVeryHidden
'this is where I need the workbook to stay invisible and display a userform if macros are enabled...
frmOnLoad.Show
End Sub
I am using Excel 2013.