Private Sub CheckBox1_Click()
ShowDocProperty.Value = Not CheckBox1.Value
End Sub
Private Sub UserForm_Initialize()
With CheckBox1
.Value = Not ShowDocProperty.Value
If .Value Then
With .Parent
.StartUpPosition = 0
.Top = 0: .Left = 0
.Height = 0: .Width = 0
End With
End If
End With
End Sub
Private Sub UserForm_Activate()
If CheckBox1.Value Then Me.Hide
End Sub
Function ShowDocProperty() As DocumentProperty
Const PropertyName As String = "ShowForm"
Rem retrieve custom document property as an object
On Error GoTo MakeProperty
Set ShowDocProperty = ThisWorkbook.CustomDocumentProperties(PropertyName)
On Error GoTo 0
Exit Function
MakeProperty:
If Err = 5 Then
Rem if property does not exist, make one
With ThisWorkbook.CustomDocumentProperties
Set ShowDocProperty = .Add(Name:=PropertyName, _
LinkToContent:=False, Type:=msoPropertyTypeBoolean, Value:=True)
End With
Else
MsgBox Err & vbCr & Error
End
End If
End Function