Results 1 to 5 of 5

Code Issue With Save Prompt Not Saving

Threaded View

  1. #1
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Code Issue With Save Prompt Not Saving

    I've been having issues saving changes in my workbook as of late, and discovered that this bit of code seems to be faulty:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Dim lngResp As Long
        If Not ThisWorkbook.Saved Then
            ThisWorkbook.Saved = True
            lngResp = MsgBox("Do you wish to save the workbook before closing?", vbYesNo)
            If lngResp = vbYes Then
                With ThisWorkbook
                     .Save
                     .Saved = True
                 End With
            End If
        End If
    End Sub
    ..for when I make changes to the workbook, and then just close it without saving manually, I get this message:

    Do you wish to save the workbook before closing?
    ..and upon choosing 'Yes', the workbook closes, but no changes are saved. What could the error be? I've attached a sample of my workbook below.

    And for reference purposes, here is where this code originated.
    Attached Files Attached Files
    Last edited by swordswinger710; 03-05-2012 at 12:59 PM.
    There is so much good in the worst of us,
    And so much bad in the best of us,
    That it hardly behooves any of us
    To talk about the rest of us.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1