title: Prevent closing of workbook
body: <p>There is <code>ABC.xls</code> file which has the macro. Now, the macro has a sub which is getting called when I press <code>Ctrl + M</code>. 
  This sub will open a Open File Dialog where the user can choose a <code>CSV</code> file. So basically, this macro is used for processing and saving <code>CSV</code> file.
  Below is the code which gets called on pressing <code>Ctrl + M</code>. </p>
  
  <pre><code>Sub runProperChangeSubroutine()             ' Assigned to shortcut key CTRL + M.
      file_name = ActiveWorkbook.Name         ' Gets the file name.
      Application.Run file_name &amp; "!ChangeSub"
  End Sub
  </code></pre>
  
  <p>When the user closes the workbook, I have to test for a condition like each row in the <code>CSV</code> has a termination string. If that termination string is not
  present, I should popup a message box to the user and prevent the closing of workbook.
  So I did the following...</p>
  
  <pre><code>Private Sub Workbook_BeforeClose(Cancel As Boolean)
      Dim improperRowNumber As Integer
      Dim BlnEventState As Boolean
      improperRowNumber = returnImproperRow()
  
      BlnEventState = Application.EnableEvents
      Application.EnableEvents = True
  
      If improperRowNumber &lt;&gt; -1 Then
          Cancel = True
          MsgBox "The row number " &amp; improperRowNumber &amp; " is not ending with '@/#'. Please correct the row before closing."
      Else
          Call saveCSV
      End If
      Application.EnableEvents = BlnEventState
  End Sub
  </code></pre>
  
  <p>On clicking of the close (X mark on top right corner, closing of workboox. I am not closing the excel.) button, I am able to see the message box but the workboox closes. I want user to make some edit if the row is not properly ended.
  Please suggest.</p>
  
  <p>Edited:
  As the above code is not working, I used <code>ThisWorkbook.Saved = False</code> after the message box as shown below...</p>
  
  <pre><code>If improperRowNumber &lt;&gt; -1 Then
      MsgBox "The row number " &amp; improperRowNumber &amp; " is not ending with '@/#'. Please correct the row before closing."
      Application.DisplayAlerts = False
      ThisWorkbook.Saved = False
      Cancel = False
  Else
  </code></pre>
  
  <p>Now it displays the "<code>Do you want to save the changes....</code>" message box. If I click on <code>Cancel</code> button on message box, the workbook is not closed.</p>
  
  <p>Is there a way to customize the message box text or buttons or hide this <code>Save</code> message box? </p>