Solved

Change from Early to Late Binding

Posted on 2007-04-03
10
572 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

696 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