I get two different errors on the same line. Sometimes this one:
Automation error: object invoked has disconnected from its clients
Instead of
Set ie = New InternetExplorerMedium
just use
Set ie = New InternetExplorer
or, for late binding:
Set ie = CreateObject("InternetExplorer.Application")
This makes the error go away.
I'm not sure why you would use InternetExplorerMedium in the first place. Quoting the small print in the documentation:
Remarks
Windows Internet Explorer 8. On Windows Vista, to create an instance of Internet Explorer running at a medium integrity level, pass
CLSID_InternetExplorerMedium(defined in exdisp.idl) toCoCreateInstance. The resultingInternetExplorerMediumobject supports the same events, methods, and properties as theInternetExplorerobject.
Are you really using IE8 on Windows Vista, and do you really want "medium integrity level", whatever that means? I didn't think so.