title: Add Action in X at userform macro VBA
body: <p>I have a userform in macro which gets the source from another workbook(test.xlsm). So I used this code below to open that workbook without showing it.</p>
  
  <pre><code>Const fromFile = "C:\Users\excel\test.xlsm"
  Dim srcBook As Workbook
  Set srcBook =   
  Application.Workbooks.Open("C:\Users\excel\test.xlsm", _
  UpdateLinks:=False, _
  ReadOnly:=True, _
  AddToMRU:=False)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/0RJif.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0RJif.png" alt="Userform"></a></p>
  
  <p>So when the macro run, the userform shown up and also the test.xlsm in background. However, there are some users who close the userform using "X" symbol at the right top corner. and sometimes, there is an error because the source (text.xlsm) didn't close properly. </p>
  
  <p>I am wondering if there is a way to add an action if the user click the "X" button in my userform? So I want to close the test.xlsm which run in background if the users click "X" button.</p>