+ Reply to Thread
Results 1 to 9 of 9

Not able to close the workbook as desired

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Not able to close the workbook as desired

    Hi guys

    I am getting a strange problem in closing my project when I click on Save & Exit button . As I think workbookbeforeclose event is called when I click on this button and so it opens the form again. Please find attached a copy of the form.

    Could anyone please solve my problem as its very urgent to resolve.
    Regards
    Aman
    Attached Files Attached Files
    Last edited by aman1234; 03-23-2009 at 11:34 AM. Reason: title change

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Not able to close the workbook as desired

    Your code calls the userform before save, so when you click save & exit on the form the code closes the workbook which means that the before-close event displays the userform again
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Not able to close the workbook as desired

    Hi Roy

    Thanks for your reply. Can you please modify my code and send it to me. I am new into vba programming so really don't know what shall i do.

    Regards
    Aman

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Not able to close the workbook as desired

    not sure what you expect it to do.

  5. #5
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Not able to close the workbook as desired

    Hi roy

    Thanks for your reply again. As you can see in the attachment file, I have a form from which I want to open a report so I have put a button "View MI Report". when this button is clicked then a worksheet opens. What I want is when user clicks on X button on the worksheet then the worksheet should be closed and form should be opened. You can see code of workbook_beforeclose event in the file attached.

    And for save & exit button , When the user clicks on this button then the whole project workbook should be closed. But in my case Workbook_beforeclose event is interfering with save & exit button code.

    I want to perform two tasks as discussed above in the right order.

    I hope you understand my problem.

    Regards
    Aman

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Not able to close the workbook as desired

    If you click on the X on the worksheet, the workbook closes so the form is no longer available.

  7. #7
    Registered User
    Join Date
    03-23-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Not able to close the workbook as desired

    Hi aman

    i think ur problem is with workbook close event.

    Raj
    Last edited by rajgud1234; 03-24-2009 at 08:29 AM.

  8. #8
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Not able to close the workbook as desired

    Hi Roy

    That was my colleague who posted the same workbook to you. We are not able to resolve this problem so everyone is posting the things to get the right answer.

    Actually, When you run the file and click on View MI report then workbook opens and when you press the X button then form is displayed. That works fine. My problem is with Save & exit button which doesn't work appropriately.
    As workbook_beforeclose event executes before this and so on first click on this button the form doesn't close.

    Hope you understand my problem.
    Regards
    Aman

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Not able to close the workbook as desired

    Quote Originally Posted by aman1234 View Post
    Hi Roy

    That was my colleague who posted the same workbook to you. We are not able to resolve this problem so everyone is posting the things to get the right answer.

    Actually, When you run the file and click on View MI report then workbook opens and when you press the X button then form is displayed. That works fine. My problem is with Save & exit button which doesn't work appropriately.
    As workbook_beforeclose event executes before this and so on first click on this button the form doesn't close.

    Hope you understand my problem.
    Regards
    Aman
    You've asked the same question - what is going off here? This is potentially wasting member's valuable time!

+ 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