Results 1 to 2 of 2
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    exit without save wbook (2000)

    i dont want to save workbook when test=0, why the code tell me to save?

    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    If TEST = "0" Then
    GoTo FINE
    End If

    Call CHIUDI(VAR_USER)
    Call EXPORTA_SHEET
    Call EXPORTA_SHEET_STORIA

    MsgBox ("RICORDATI DI RIPOSIZIONARE LA STAMPANTE DI EXTRA SU -STAMPANTE-"), vbInformation

    Application.DisplayAlerts = False
    ActiveWorkbook.Save
    Application.DisplayAlerts = True

    FINE:

    Excel.Application.Quit

    End Sub

  2. #2
    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: exit without save wbook (2000)

    When test = "0" the routine tells excel to quit, so if you have made changes to the workbook, excel will ask you to save before quitting.

    Try adding the line:

    FINE:
    <font color=red>ActiveWorkbook.Saved = True</font color=red>
    Excel.Application.Quit
    End Sub

    to lie to excel and tell it that the file already has been saved, so it won't worry about saving it...

    Steve

Posting Permissions

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