+ Reply to Thread
Results 1 to 4 of 4

Workbook_BeforeSave Question Function Question

  1. #1
    Registered User
    Join Date
    03-28-2015
    Location
    Somerset, NJ
    MS-Off Ver
    2010
    Posts
    6

    Workbook_BeforeSave Question Function Question

    Hello Experts,

    I am using the Workbook_BeforeSave function for the first time. I have it working such that the "work" inside the function gets done, but when I close the Excel workbook, I am prompted to save the file once again, without having made any additional changes to the workbook. My sense is I am doing something fundamentally wrong. Within the Workbook_BeforeSave function, I am also trying to save 2 additional text files besides the Excel workbook. I don't know if this is complicating things or not. Any help would be appreciated. Thanks in advance.
    Here is my code.
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Workbook_BeforeSave Question Function Question

    Hi thomasmc,

    a. Unrelated to your problem, you should probably change the following to turn events back on and to turn on protection:
    Please Login or Register  to view this content.
    b. It looks like you close the Workbook somewhere else other than this routine, either through code or manually. You probably need one of the following (which fools Excel into thinking the Workbook has been saved) somewhere in your code, when you are CERTAIN that it is SAFE to close the file without saving:
    Please Login or Register  to view this content.
    You may also need a global variable to indicate when it is OK to use the .saved construct.


    -----------------------------
    If you need additional help, please attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    Lewis

  3. #3
    Registered User
    Join Date
    03-28-2015
    Location
    Somerset, NJ
    MS-Off Ver
    2010
    Posts
    6

    Re: Workbook_BeforeSave Question Function Question

    Hi LJMetzger

    Thank you for the quick response. I implemented your first suggestion of turning events and protection back on. Good catch.

    I also added
    ThisWorkbook.Saved = True

    right after Exit_Sub. But the behavior is still the same. When I close the Excel workbook, I am prompted to save the file once again, without having made any additional changes. Perhaps the .Saved should be placed somewhere else?

  4. #4
    Registered User
    Join Date
    03-28-2015
    Location
    Somerset, NJ
    MS-Off Ver
    2010
    Posts
    6

    Re: Workbook_BeforeSave Question Function Question

    Hi LJMetzger,

    I took my own suggestion and moved the .Saved to the very last statement in the Workbook_BeforeSave function. That worked! Now the file saves cleanly without and double save requests. Thank you for all of your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Objective Question: High light the right answer with green before next question.
    By ebin charles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2015, 12:38 PM
  2. database question, excel data sorting question
    By weblisterltd.com in forum Excel General
    Replies: 1
    Last Post: 12-17-2014, 01:35 PM
  3. code to progressively go throughly question based on answer to first question
    By Ishwarind in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2014, 06:48 AM
  4. [SOLVED] Question regarding conditional format question that covers two range criteria
    By lilsnoop in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-06-2013, 12:32 PM
  5. Two question, numeric code question and subtraction of two columns?
    By mgsweden78 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-18-2008, 02:50 AM
  6. Workbook_BeforeSave question
    By Barb Reinhardt in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-11-2006, 11:20 AM
  7. Workbook_BeforeSave question-with external links.
    By Frederick Chow in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-21-2006, 03:30 PM

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