Solved

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

Posted on 2013-01-19
6
799 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
6 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
I made the changes but got the following error.

Run-time error '429'
ActiveX componet cant create object.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:seanlhall
Comment Utility
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 33

Expert Comment

by:Norie
Comment Utility
Sorry about that, forgot to leave out the 60 part.

I think that indicates the version.
0
 
LVL 84
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now