Solved

How do I late bind MS XMl, v6.0 in MS Access 2007?

Posted on 2013-01-19
6
943 Views
Last Modified: 2013-02-01
I have a function the retrieves the users IP address from a web site. The problem is, for this to work I would have to add a reference to Microsoft XML, 6.0 (msxml6.dll). I do not want to do that as it will cause problems with deployment. I don't not completely understand late binding be it sounds like what I am looking for.

Private Sub GetUserIP_Click()
    Dim strIP As String
    Dim strText As String
    Dim lngPos1 As Long
    Dim lngPos2 As Long
     
    Dim httpReq As New MSXML2.XMLHTTP60
    ' fetch the data
   
    httpReq.Open "Get", "http://www.whatsmyip.us", False
    httpReq.send
    strText = httpReq.responseText
    ' find the location of the IP address in the response
    lngPos1 = InStr(strText, "Your IP is:")
    ' calculate the position of the first digit
    lngPos1 = lngPos1 + 99
    ' find the location of the closing tag
    lngPos2 = InStr(lngPos1, strText, "<")
    ' extract the IP
    strIP = Mid(strText, lngPos1, lngPos2 - lngPos1)
    ' report to user
    MsgBox strIP
End Sub
0
Comment
Question by:seanlhall
[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
6 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 38796398
Replace this,
Dim httpReq As New MSXML2.XMLHTTP60

Open in new window

with this.
Dim httpReq As Object

    Set httpReq = CreateObject("MSXML2.XMLHTTP60")

Open in new window

0
 
LVL 77

Expert Comment

by:peter57r
ID: 38796451
Just to be sure you're clear on one point...(sorry if this is grandmother and eggs )
Using late binding doesn't mean that you avoid using that dll.  It just means that Access doesn't care which version of the dll is installed.
0
 

Author Comment

by:seanlhall
ID: 38797220
I made the changes but got the following error.

Run-time error '429'
ActiveX componet cant create object.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:seanlhall
ID: 38797253
I got it to work. I change it to this:

Dim httpReq As Object

 Set httpReq = CreateObject("MSXML2.XMLHTTP") 

Open in new window

0
 
LVL 34

Expert Comment

by:Norie
ID: 38797306
Sorry about that, forgot to leave out the 60 part.

I think that indicates the version.
0
 
LVL 85
ID: 38798057
You also must be sure to use ONLY those components of that library which are available in the user's version. As  peter indicates, Late Binding will help if you're not sure what VERSION you're dealing  with, but it doesn't absolve you of some due diligence regarding syntax and versions. If you're sure that all users are running at least Version4.0 of a library, for example, you can make sure your code is compliant with 4.0 - which means you can't make use of features introduced AFTER Version 4.0. If you have no idea what version your users will be running, then you must be sure to make it compliant with ALL versions of the library (which means no new features introduced after Version 1)
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

691 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