Hi all
I am fairly new to VBA coding and I have found this site very useful for helping me to understand and fix previous problems I have had. I cannot find an answer for my current problem, however, despite extensive internet searches. I have created a userform that allows users to scrape information from a database and then fill out one of several Microsoft word documents based on the users choices from the userform.
This all works fine but the userform has an exit control button for the user to exit the workbook once they are finished. Due to the nature of our work, the user often has several other workbooks open at the same time.
My problem is that after the user exits the userform's workbook, the other workbooks that are open refuse to close, either by clicking on the X or by using file - close
I have built a much simpler version of my userform to test for ways to resolve this but I am stumped
Here is the code I am using in my test userform as I cannot share the original.
Sorry for all the little comments in the code, this is to help me remember what everything does as I learn
Thanks in advance
I am fairly new to VBA coding and I have found this site very useful for helping me to understand and fix previous problems I have had. I cannot find an answer for my current problem, however, despite extensive internet searches. I have created a userform that allows users to scrape information from a database and then fill out one of several Microsoft word documents based on the users choices from the userform.
This all works fine but the userform has an exit control button for the user to exit the workbook once they are finished. Due to the nature of our work, the user often has several other workbooks open at the same time.
My problem is that after the user exits the userform's workbook, the other workbooks that are open refuse to close, either by clicking on the X or by using file - close
I have built a much simpler version of my userform to test for ways to resolve this but I am stumped
Here is the code I am using in my test userform as I cannot share the original.
Code:
Sub StartUserform()
'calls userform
UserForm1.Show
End Sub
Private Sub push_Click()
'simple test for other option on userform
Call TestMacro
End Sub
Private Sub ExitButton_Click()
'exit button on userform
Unload Me
Call CloseBook
End Sub
Sub TestMacro()
'for userform option 1
MsgBox "It Works!!"
End Sub
Sub CloseBook()
'to exit workbook
Windows("HO.XLSX").Close
End Sub
Sorry for all the little comments in the code, this is to help me remember what everything does as I learn
Thanks in advance