Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cancel Workbook Close (XL97; SR2)

    Does anyone know if it is possible to cancel a workbook close process via vba code? I'm using the following code and if two ranges are not equal a message appears indicating so but I need to cancel the close process itself.

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    If Range("R_one") <> Range("R_two") Then
    MsgBox "Two Ranges do not equal"
    ' Insert Code Here to cancel workbook close feature...
    End If
    End Sub

    Thanks,
    John

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

    Re: Cancel Workbook Close (XL97; SR2)

    <' Insert Code Here to cancel workbook close feature...>

    Replace above with <pre>Cancel = True </pre>


    Andrew C

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cancel Workbook Close (XL97; SR2)

    Andrew,

    Thank You!

    What can I say, so close and yet so far away from the solution.

Posting Permissions

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