View Single Post
 
Old 03-31-2019, 02:29 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Basically you would use your close macro to set the document variable e.g.
Code:
Private Sub BtnExitl_Click()
    ThisDocument.Variables("varShow").value = "True"
    ThisDocument.Save
    Application.Quit
End Sub
and then look for that variable when you open the document again. If the variable is not present then show the userform.

Code:
Private Sub Document_Open()
Dim oVar As Variable
Dim bVar As Boolean
    For Each oVar In ThisDocument.Variables
        If oVar.Name = "varShow" Then
            If oVar.value = "True" Then
                bVar = True
                Exit For
            End If
        End If
    Next oVar
    If bVar = False Then UserForm1.Show
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote