SeniorNewbie
Board Regular
- Joined
- Jul 9, 2023
- Messages
- 77
- Office Version
- 2021
- 2019
- Platform
- Windows
- MacOS
Hi out there,
my userform is set up with a dynamic caption. The value is taken from a CustomDocumentProperty (CDP) and counts the number of saved versions of the workbook. The update of the CDP = CDP + 1 is triggerd by saving the file. The status saved/not saved I take from workbook properties. To here everything works fine.
Now I want to block/terminate/hide my userform, if the file ist not yet saved and let the user know by a msgbox (what works as well). My attemps zu make this in the userform_initialize code weren't successfull. The userform calls this code (see below) in a module but appears anyway.
Any ideas? THX a lot in advance!
Senior
my userform is set up with a dynamic caption. The value is taken from a CustomDocumentProperty (CDP) and counts the number of saved versions of the workbook. The update of the CDP = CDP + 1 is triggerd by saving the file. The status saved/not saved I take from workbook properties. To here everything works fine.
Now I want to block/terminate/hide my userform, if the file ist not yet saved and let the user know by a msgbox (what works as well). My attemps zu make this in the userform_initialize code weren't successfull. The userform calls this code (see below) in a module but appears anyway.
VBA Code:
Sub isSaved()
Dim isSaved As Boolean
isSaved = ThisWorkbook.Saved
If isSaved = False Then
MsgBox "The workbook must be saved first", , isSaved
UserForm1.Hide
Exit Sub
End If
End Sub
Any ideas? THX a lot in advance!
Senior