Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Trenton, Ontario
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Close Workbook with VB (2000)

    When I use the code ActiveWorkbook.Close in a macro, what is the VB code to say "No" to the question "Do you want to save the changes you have made to Sheet1?"?

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Close Workbook with VB (2000)

    Try:

    <pre> Application.DisplayAlerts = False
    ActiveWorkbook.Saved = True
    ActiveWorkbook.Close
    Application.DisplayAlerts = True
    </pre>

    Legare Coleman

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Close Workbook with VB (2000)

    Or try this alternative

    ActiveWorkbook.Close SaveChanges:=False

    Andrew C

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Close Workbook with VB (2000)

    OR the even shorter:

    <pre>ActiveWorkbook.Close (False)</pre>


    Steve

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Close Workbook with VB (2000)

    Shortest <g>:

    Activeworkbook.Close False
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Close Workbook with VB (2000)

    Even shorter

    Activeworkbook.Close 0

    Andrew

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Close Workbook with VB (2000)

    You win! <img src=/S/fanfare.gif border=0 alt=fanfare width=31 height=23>
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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