Solved

Change from Early to Late Binding

Posted on 2007-04-03
10
575 Views
Last Modified: 2012-05-05
Could someone assist me in converting from early to late binding.  My attempts at changing the delcarations and set statements have given me a runtime error '420' ActiveX component can't create object.  This was working fine using early binding, however the situation requires a late binding solution.  I have simplified the Code somewhat to make it readable.  

Public Function GetMap(strValue As String)
'need shdocvw.dll - Microsoft Internet Controls
Dim strUrl As String
Dim shlShellWindows As Object
Dim expExplorer As Object
Set shlShellWindows = CreateObject("SHDocVw.ShellWindows")
strUrl = "www.google.com"

On Error Resume Next
'Build the url string
strUrl = strUrl & strValue
'Check and see if there are any open map windows to reuse
For Each expExplorer In shlShellWindows
  If Left(expExplorer.LocationName, 7) = "Mapping" Then
    expExplorer.Navigate strUrl
    Exit Function
  End If
Next
'Open browser window and launch map
Dim ie As Object
Set ie = CreateObject("SHDocVw.InternetExplorer")
ie.Navigate strUrl
ie.Visible = True
Set expExplorer = Nothing

End Function
0
Comment
Question by:BillPowell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 39

Expert Comment

by:stevbe
ID: 18845351
Set shlShellWindows = CreateObject("Shell.Application")
Set ie = CreateObject("Shell.InternetExplorer")
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 18845484
CreateObject("InternetExplorer.Application")
0
 
LVL 11

Author Comment

by:BillPowell
ID: 18846127
Guys, I need to stick to the Microsoft Internet Controls dll if possible.  In code Im checking all internet explorer windows currently open to see if they are already at the site I need them to be.  If they are, I grab that window and change the LocationName.  If none of those windows are of the specified website, I open a new internet explorer window and navigate to a url.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 12

Expert Comment

by:jkaios
ID: 18848135
Where exactly (what line) in your code does the error occurs?
0
 
LVL 11

Author Comment

by:BillPowell
ID: 18848319
This is the offending line:
Set shlShellWindows = CreateObject("SHDocVw.ShellWindows")
0
 
LVL 39

Assisted Solution

by:stevbe
stevbe earned 100 total points
ID: 18850079
EDDTK has is correctly for an individual ie window
    Set ie = CreateObject("InternetExplorer.Application")

0
 
LVL 39

Expert Comment

by:stevbe
ID: 18850185
and apparently  M$ neds to update their docs as I tried with the indo they have posted here:
http://msdn2.microsoft.com/en-us/library/aa969392.aspx
0
 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 100 total points
ID: 18850257
Don't think you can call

Set shlShellWindows = CreateObject("SHDocVw.ShellWindows")

because it is hidden and must be go through the object to create.

I try this one

Set shlShellWindows = CreateObject("Shell.Application")

but has no luck

The other one should be

Set ie = CreateObject("InternetExplorer.Application")
0
 
LVL 28

Accepted Solution

by:
Ark earned 300 total points
ID: 18874755
Private Sub Command1_Click()
   Dim sha, shw
   Set sha = CreateObject("Shell.Application")
   For Each shw In sha.windows
      Debug.Print shw.LocationURL
   Next
End Sub
0
 
LVL 11

Author Comment

by:BillPowell
ID: 18875412
Ok, heres what worked finally:
Public Function GetMap(strValue As String)
Dim strUrl As String
Dim shlShellWindows As Object
Dim expExplorer As Object
Set shlShellWindows = CreateObject("Shell.Application")
strUrl = "www.google.com"

'Build the url string
strUrl = strUrl & strValue
'Check and see if there are any open map windows to reuse
For Each expExplorer In shlShellWindows.Windows
  If Left(expExplorer.LocationName, 7) = "Google" Then
    expExplorer.Navigate strUrl
    Exit Function
  End If
Next
'Open browser window and launch map
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate strUrl
ie.Visible = True
End Function

Thank for the help guys!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question