BillPowell
asked on
Change from Early to Late Binding
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.Shel lWindows")
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.LocationN ame, 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.Inte rnetExplor er")
ie.Navigate strUrl
ie.Visible = True
Set expExplorer = Nothing
End Function
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.Shel
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.LocationN
expExplorer.Navigate strUrl
Exit Function
End If
Next
'Open browser window and launch map
Dim ie As Object
Set ie = CreateObject("SHDocVw.Inte
ie.Navigate strUrl
ie.Visible = True
Set expExplorer = Nothing
End Function
CreateObject("InternetExpl orer.Appli cation")
ASKER
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.
Where exactly (what line) in your code does the error occurs?
ASKER
This is the offending line:
Set shlShellWindows = CreateObject("SHDocVw.Shel lWindows")
Set shlShellWindows = CreateObject("SHDocVw.Shel
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
http://msdn2.microsoft.com/en-us/library/aa969392.aspx
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.Applic ation")
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.LocationN ame, 7) = "Google" Then
expExplorer.Navigate strUrl
Exit Function
End If
Next
'Open browser window and launch map
Dim ie As Object
Set ie = CreateObject("InternetExpl orer.Appli cation")
ie.Navigate strUrl
ie.Visible = True
End Function
Thank for the help guys!
Public Function GetMap(strValue As String)
Dim strUrl As String
Dim shlShellWindows As Object
Dim expExplorer As Object
Set shlShellWindows = CreateObject("Shell.Applic
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.LocationN
expExplorer.Navigate strUrl
Exit Function
End If
Next
'Open browser window and launch map
Dim ie As Object
Set ie = CreateObject("InternetExpl
ie.Navigate strUrl
ie.Visible = True
End Function
Thank for the help guys!
Set ie = CreateObject("Shell.Intern