I have a workbook with a userform that closes the workbook when the user closes the form.
Sub Auto_Open()
Sheets("Background").Select
MgrForm.Show
ActiveWorkbook.Close (False)
End Sub
One of the command buttons, when clicked, opens another workbook, feeds some data into it, closes and saves that workbook (I have my reasons), then opens it again, running the auto_open subroutine, which is similar to the above (opening a userform, and then closing the workbook when finished). It is my intention that at that point, the 1st workbook would also close, but it doesn't. Here's the code:
Workbooks.Open Filename:=Range("DBPath").Value
Sheets("Prestarter").Select
' Copies data to workbook
ActiveWorkbook.Close SaveChanges:=True
Workbooks.Open Filename:=Range("DBPath").Value
ActiveWorkbook.RunAutoMacros xlAutoOpen
Me.Hide
I put a debug stop on the "ActiveWorkbook.RunAutoMacros xlAutoOpen" line and on the "Me.Hide" line. It stops on the first one, and when I proceed, it opens the 2nd workbook and userform correctly, and closes it when I hit the Close button, but never reaches the Me.Hide debug stop. It just exits from the user form but doesn't close the workbook. Any suggestions on how why it doesn't hit the Me.Hide code?
Bookmarks