troubleshooting Question

switch 'set x = new xxxx.yyyyy' to late binding for arbitrary object types

Avatar of rberke
rberkeFlag for United States of America asked on
Microsoft AccessVisual Basic ClassicMicrosoft Excel
9 Comments3 Solutions862 ViewsLast Modified:
I have posted a snippet of some working code.

Right now the only way to make it work is to set a reference to "microsoft internet controls".    I want the code to be portable, so I tried to use late binding to eliminate the need for a reference.  I can't figure out what to put into the createobject.  line 13 fails

Function QuitIE() As Long
 ' returns number of quits performed  (up to 50)
     Dim shellWins As Object '  SHDocVw.ShellWindows

' this works  Set shellWins = New SHDocVw.ShellWindows
    Set shellWins = CreateObject("Shell.Application")  '<===== (1) does NOT WORK
 
     Dim explorer As SHDocVw.InternetExplorer    ' (2) changing this to As Object does not help

    Dim repeat As Boolean
    Do
        repeat = False
       ' next line fails object does not support this method
        For Each explorer In shellWins


I will give points to whoever can solve this particular problem.
But, I will give the Accepted Answer to anyone that can give me a general answer, In other words I want  to be able to change working code from
       set x = new wwwwwww.xxxxxx      
into set x = createobject ("yyyyy.zzzzz") where w,x,y and z are anything
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 3 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros