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.
picture : https://ibb.co/krd66R
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">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>
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.
I am wondering if there is a way to add an action if the user clicks the "X" button in my userform? So I want to close the test.xlsm which run in background if the users click "X" button.
picture : https://ibb.co/krd66R
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">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>
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.
I am wondering if there is a way to add an action if the user clicks the "X" button in my userform? So I want to close the test.xlsm which run in background if the users click "X" button.