Solved

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

Posted on 2013-01-19
6
878 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

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.

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

791 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