Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-12-2023, 04:49 AM
ksor ksor is offline Problems with ThisWorkbook.Saved not working ? Windows 10 Problems with ThisWorkbook.Saved not working ? Office 2016
Advanced Beginner
Problems with ThisWorkbook.Saved not working ?
 
Join Date: Feb 2018
Location: Århus V, Denmark
Posts: 74
ksor is on a distinguished road
Default Problems with ThisWorkbook.Saved not working ?


I have a workbook with few sheets in it.

I the beforeClose I use ThisWorkbook.Saved to show a enhanged dialog explaining in danish the situation for the user - it's just the normal problematic ... do you want to save or not or cancel then close the file - here is the code:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'   Application.DisplayFormulaBar = True
'   ActiveWindow.Zoom = initZoom
'   ActiveSheet.Range("A1").Select
    '
    Dim svar As Byte
    If ThisWorkbook.Saved = False Then
        svar = MsgBox("Du har lavet ændringer på et af arkene - bevidst eller ubevidst !" & vbLf & vbLf & _
                 "Er du USIKKER på, hvad du har lavet --> så svar NEJ til at gemme !" & vbLf & vbLf & _
                 "Overvej nøje HVAD du har lavet, og besvar så dette: 'Vil du gemme ?'", _
                 vbYesNoCancel + vbDefaultButton2, "ADVARSEL <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
        If svar = vbYes Then
            ThisWorkbook.Save
        ElseIf svar = vbNo Then
            ThisWorkbook.Saved = True
        ElseIf svar = vbCancel Then
            Cancel = True
        End If
    End If
End Sub
If I just open the file and close it again the dialog shows up ... as though the ThisWorkbook.Saved is False ... but I'm not aware of making any changes or having some vba that do any changes to the file !

How can I find out where the chance happens ?
Reply With Quote
  #2  
Old 07-12-2023, 04:58 AM
ksor ksor is offline Problems with ThisWorkbook.Saved not working ? Windows 10 Problems with ThisWorkbook.Saved not working ? Office 2016
Advanced Beginner
Problems with ThisWorkbook.Saved not working ?
 
Join Date: Feb 2018
Location: Århus V, Denmark
Posts: 74
ksor is on a distinguished road
Default

OK, it seems like I change something in the opening:


Code:
    ActiveWindow.DisplayGridlines = False
    Application.DisplayFormulaBar = False
    ActiveWindow.DisplayHeadings = False
If I comment these lines ... it works !

... but I don't think this have to do with anything in the FILE it's Excel settings - right ?

Last edited by ksor; 07-12-2023 at 09:51 PM.
Reply With Quote
Reply

Tags
excel 2019, vba code



Similar Threads
Thread Thread Starter Forum Replies Last Post
Track changes saved to pdf with only red vertical lines saved peterm Word 4 09-16-2020 07:37 PM
Problems with Outlook: secure settings no longer working AlanC Outlook 1 07-06-2018 05:03 AM
Problems with ThisWorkbook.Saved not working ? Two problems, maybe related: c/paste not working, Word won't delete Feeb63 Word 2 03-14-2015 05:33 PM
Video not working when saved as .ppt But does when saved as .pptx patientxwolf PowerPoint 5 01-24-2014 02:16 PM
Problems working in a partially protected document Autumn Excel 0 02-11-2009 03:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:41 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