+ Reply to Thread
Results 1 to 7 of 7

Minor error gives problem in code in Workbook_BeforeClose event

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Minor error gives problem in code in Workbook_BeforeClose event

    HI I have below code which give me little problems. When there is a value in cell D10. a messagebox pop up and ask me to save the invoice , before i can close the workbook. It works ok. If there is no value it close right away. If there is a value it save the worksheet, but dont close the workbook. So basically its works.

    I would like that if there is value in cell D10, dont save the worksheet, but dont close the workbook off course..But only save, when i have saved the invoice, as it ask me to do.
    Its more that when there will be many invoices, it will take un nesssary time. I am sure it is maybe only a little thing. But i have played around and cant make it work.

    And off course the hold idea is that it save without promt the user.

    Please have a look at the code.

    Sincerely
    Abjac


    Please Login or Register  to view this content.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,767

    Re: Minor error gives problem in code in Workbook_BeforeClose event

    Just remove that if condition area from your code

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Minor error gives problem in code in Workbook_BeforeClose event

    HI Sixthsense and thanks for your answer. I need this line to be included.

    Please Login or Register  to view this content.
    That is the problem. It does that if there is any value in this cell, you need to press another button to save the sheet. And it dont close the workbook, before i have saved the sheet.

    It works but when this message pop up, it also save the sheet, but dont close it. And its un nessasary that it save here.

    So i need that included, but it shall not save the sheet. It shall only save, when the workbook close.


    Please have a look

    Sincerely

    Abjac

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,767

    Re: Minor error gives problem in code in Workbook_BeforeClose event

    May be this...

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Minor error gives problem in code in Workbook_BeforeClose event

    HI Tried it but it still dont work.

    If D10 is empty it have to save, with out promt the user, but if it have value it shall not save and come with the MsgBox ("You Have to save the invoice, before you can close the workbook")

    I have tried alot but cant really make it work.
    SO seems to be a more difficult one to make.

    Sincerely

    Abjac

  6. #6
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Minor error gives problem in code in Workbook_BeforeClose event

    Hi. I have now tried to post this in other board, to see if any there can solve this problem.

    Thanks

    http://www.mrexcel.com/forum/excel-q...ml#post3448820

  7. #7
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Minor error gives problem in code in Workbook_BeforeClose event

    Finally after playing around alot i found out of this.
    The working code is like this and it only save when there is no value in cell D10

    Insert Me.Saved = False did the trick


    Thanks to my self haha

    Sincerelyu
    Abjac

    Please Login or Register  to view this content.

+ Reply to Thread

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