Solved

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

Posted on 2013-01-19
6
857 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
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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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 33

Expert Comment

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

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

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…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

773 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