Here is what I usually do. I do not use a Msgbox
. The reason is very simple. Sometimes I need to show lot of information in the Disclaimer
. However if you still need to use a MsgBox
then adapt it from below.
Do this
Insert a UserForm
as shown in the image below. Place a Textbox
and two CommandButtons
. In the properties of the Textbox
, make it multi line and scroll-able (Vertical only). Name the CommandButtons
as shown in the image. Also change the Textbox
.Locked
property to True
so the text in the Textbox
is read-only at runtime.
Next, place this code in the UserForm
Const sLiabMsg As String = "Blah Blah Blah. Your Disclaimer goes here"
Private Sub UserForm_Initialize()
bAllow = False
TextBox1.Text = sLiabMsg
End Sub
Private Sub CommandButton1_Click()
bAllow = True
Unload Me
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Next insert a Module
and paste this one line in it
Public bAllow As Boolean
Next in the ThisWorkbook
code area, paste this code
Private Sub Workbook_Open()
ThisWorkbook.Windows(1).Visible = False
UserForm1.Show
If bAllow = True Then
ThisWorkbook.Windows(1).Visible = True
Sheet1.Visible = xlSheetVisible
Sheet1.Activate
Else
ThisWorkbook.Close (False)
End If
End Sub
And you are done.
solved VBA MsgBox ‘Liability Disclaimer’?