Microsoft Office Tutorials and References
In Depth Information
Option to Show Message Only Once
‘Set ScreenUpdating to False.
Application.ScreenUpdating = False
‘Delete the dialog sheet if by chance it exists.
‘It will be added in the next step.
On Error Resume Next
Application.DisplayAlerts = False
ActiveWorkbook.DialogSheets(strDialogName).Delete
Application.DisplayAlerts = True
Err.Clear
‘Create and name the new dialog sheet, then hide it.
Set dlgShowMessageOnce = ActiveWorkbook.DialogSheets.Add
With dlgShowMessageOnce
.Name = strDialogName
.Visible = xlSheetHidden
‘Size the dialog sheet frame (the dialog box you will actually see),
‘and give its title bar a meaningful caption.
With .DialogFrame
.Height = 130
.Width = 210
.Caption = “Just so you know...”
End With
‘Hide the Cancel default button that comes with dialog sheets,
‘as the checkbox is the key to halting the showing of the dialog.
.Buttons(“Button 3”).Visible = False
‘Add a Label at the top of the dialog, distance from
‘Left, Top, Width, Height.
.Labels.Add 100, 50, 180, 18
‘Caption the Label.
.Labels(1).Caption = “You changed a cell in range B2:B10.”
‘Position the dialog’s default OK button.
With .Buttons(“Button 2”)
.Visible = True
.Left = 150
.Top = 80
End With
‘Add the checkbox with caption, distance from
‘Left, Top, Width, Height.
.CheckBoxes.Add 100, 120, 140, 18
With .CheckBoxes(1)
.Caption = “Do not show this message again.”
.OnAction = “myCheckBox”
End With
‘Set ScreenUpdating to True.
Application.ScreenUpdating = True
If .Show = False Then
‘The X Cancel button was clicked on the title bar so delete the dialog sheet.
Application.DisplayAlerts = False
Search JabSto ::




Custom Search