Microsoft Office Tutorials and References
In Depth Information
Option to Show Message Only Once
.Delete
Application.DisplayAlerts = True
End If
End With ‘for the dialog frame.
End Sub
Private Sub myCheckBox()
‘If the checkbox is checked (Value = 1) set the Boolean variable to False,
‘otherwise set it to True.
If dlgShowMessageOnce.CheckBoxes(Application.Caller).Value = 1 Then
blnMessage = False
Else
blnMessage = True
End If
End Sub
‘Delete the dialog sheet if it exists.
Private Sub DeleteDialog()
With Application
.ScreenUpdating = False
.DisplayAlerts = False
On Error Resume Next
DialogSheets(“ShowOnce”).Delete
Err.Clear
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub
A final piece of precautionary code I install in the ThisWorkbook module is to make sure that if the
workbook is opened, closed, activated, or deactivated, the custom dialog sheet is deleted if it exists.
Sometimes, at a critical moment such as a power failure or some odd circumstance, the dialog sheet
might exist in the workbook, and you just want to make sure you cover your bases with no extra
dialog sheets having accumulated when you open the workbook again. These workbook-level
procedures handle the task of monitoring the proper absence of an unwanted dialog sheet.
‘As a precaution, delete the dialog sheet if by chance it exists
‘when the workbook is opened, closed, activated, or deactivated.
‘The default Boolean value is True.
Private Sub Workbook_Open()
Run “DeleteDialog”
blnMessage = True
End Sub
Private Sub Workbook_Activate()
Run “DeleteDialog”
End Sub
Private Sub Workbook_Deactivate()
Run “DeleteDialog”
End Sub
Search JabSto ::




Custom Search