Hello,
On my userform i have an OK button and a Refresh userform button , and an Userform initialize.
When somebody has entered all the data they press the OK button and it all the data enters on a worksheet. Then it closes.
Because of this..
ActiveWorksheet.Close True
I also have a timer which closes it if there is no activity.
Private Sub UserForm_Activate()
startTimer = Timer
Do While Timer < (startTimer + 15)
DoEvents
Loop
MsgBox " Je bent 15 seconden inactief geweeest, de file sluit nu."
ActiveWorkbook.Close True
Application.ScreenUpdating = True
And i have a Update refresh button.
And last but not least , on initialize it opens the file again.
set wb = Workbooks.Open("Z:\VBA gekloot\Userform\Voortgangproduktiestart.xls")
The problem: Many times because of the timer or OK button it tries to close the file while there is no file open which gives an ERROR.
Or the person presses Update/refresh before the file is closed and then the userform initializes and tries to open the file again which causes the error , or popup : This file already open are you sure blablalbla.
Solution : A way to check if workbook is open else close it. I tried: If WorkbookIsOpen then Workbook(name.xls).close true
but cannot figure out how to do it.
Bookmarks