I have some code that automates Internet Explorer. I have IE.Visible set to True so that the user can make sure all data is being entered correctly. The problem I'm running into is that if the user closes the IE before the sub is done running then at the end where I have IE.Quit, it breaks and gives me runtime error "Application has disconnected from client". So I wanted to put an If statement in to check if the IE window had been closed, but I can't seem to figure out exactly how to do it, which seems simple to me. I put this code, and it doesn't seem to work the way I was hoping.
Code:
If Not IE is Nothing Then
IE.Quit
Set IE = Nothing
Else
Exit Sub
End If