Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-30-2019, 08:08 PM
matapagi2019 matapagi2019 is offline The Word userform checkbox (checked/unchecked) is not saved on the Application Quit Windows XP The Word userform checkbox (checked/unchecked) is not saved on the Application Quit Office 2007
Novice
The Word userform checkbox (checked/unchecked) is not saved on the Application Quit
 
Join Date: Mar 2019
Posts: 12
matapagi2019 is on a distinguished road
Default The Word userform checkbox (checked/unchecked) is not saved on the Application Quit


In Ms Word, I need a form that contains a Checkbox (ChBoxDisplay) and a Button (BtnExit). If ChBoxDisplay is checked the Userform1.hide, and if it is not checked the Userform1.show.
In the code below, when ChBoxDisplay is checked, and then the MS Word application exits by the Application.Quit command, the checkbox on ChBoxDisplay is not saved.

Code:
Private Sub BtnExitl_Click()
    Application.Quit SaveChanges:=True
End Sub

Private Sub Document_Open()
If UserForm1.ChBoxDisplay.Value = True Then
        UserForm1.Hide
    Else
        UserForm1.Show
    End If
End Sub
How to keep ChBoxDisplay Checked or unchecked when Ms Word Quit?

All help is highly expected and I am very grateful.
Reply With Quote
  #2  
Old 03-30-2019, 09:07 PM
gmayor's Avatar
gmayor gmayor is offline The Word userform checkbox (checked/unchecked) is not saved on the Application Quit Windows 10 The Word userform checkbox (checked/unchecked) is not saved on the Application Quit 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

Use the exit from the userform to set a document variable value to true or false then read that document variable value to determine whether to show the userform or not when the document is opened.
__________________
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
  #3  
Old 03-31-2019, 12:45 AM
matapagi2019 matapagi2019 is offline The Word userform checkbox (checked/unchecked) is not saved on the Application Quit Windows XP The Word userform checkbox (checked/unchecked) is not saved on the Application Quit Office 2007
Novice
The Word userform checkbox (checked/unchecked) is not saved on the Application Quit
 
Join Date: Mar 2019
Posts: 12
matapagi2019 is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
Use the exit from the userform to set a document variable value to true or false then read that document variable value to determine whether to show the userform or not when the document is opened.
Thank you @gmayor for your fast response and your assistance. But maybe because of my stupidity, I can't understand what you mean yet, and I can't implement it yet.

Can you explain it more specifically ??

Thanks a lot.
Reply With Quote
  #4  
Old 03-31-2019, 02:29 AM
gmayor's Avatar
gmayor gmayor is offline The Word userform checkbox (checked/unchecked) is not saved on the Application Quit Windows 10 The Word userform checkbox (checked/unchecked) is not saved on the Application Quit 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
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA in Word 2010 to show certain text only when a YES checkbox is checked kdsim Word VBA 0 05-16-2018 05:16 AM
The Word userform checkbox (checked/unchecked) is not saved on the Application Quit Merged Checkbox Fields Always Checked pdxplorer Mail Merge 11 12-20-2017 12:37 PM
Checkboxes are unchecked in Listbox that were checked off before.How can I stop this? Rochelle711 Excel Programming 0 06-22-2014 06:16 PM
The Word userform checkbox (checked/unchecked) is not saved on the Application Quit Checkbox on Userform result in Text in Word Dolfie_twee Word VBA 1 06-22-2010 07:54 AM
Excel 2003 will not terminate with application.quit Peter Schellenbach Excel 12 03-14-2006 05:28 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft