So there was a problem with this:

With CreateObject("Shell.Application").Windows
    If .Count > 0 Then
        Set IE = .Item(0) ' or .Item(.Count - 1)
    Else
        Set IE = CreateObject("InternetExplorer.Application")
        IE.Visible = True
    End If
End With
however im not sure why because im not sure what it does. Could anyone explain what this actually means?