using xml parser in macro

Rbartlem

Board Regular
Joined
Jun 9, 2004
Messages
172
ok I am trying to get this macro to get the longitude and latitude and send a map. I have most of it working I think but I can't get the xml parser to find longitude or latitude. I want to make it work alone and with excel so that maybe a1 you put an IP address, click a button and it emails you with maps to the longitude and latitude of that IP. Anyone have any ideas how to get it to parse the document the right way?

Code:
Dim WSHShell
Dim Message
Dim Title
Title = "Locate IP Script By Gumby"
Text1="Oops!"
Set WSHShell = WScript.CreateObject("WScript.Shell")
Result1 = InputBox("What IP Would You Like To Search?",Title,"192.168.0.1", 4000, 2000)
Result2 = InputBox("What Is Your Email?",Title,"@Gmail.com", 4000, 2000)
Result3 = InputBox("What is your SMTP server?",Title,"smtp.xxxx.net", 4000, 2000)
If Result1 = "" Then
WScript.Echo Text1
Else
End If
URL = "http://www.geobytes.com/IpLocator.htm?GetLocation&template=valuepairs.txt&IpAddress=" & Result1
set xml = CreateObject("Microsoft.XMLHTTP")
xml.async=false
xml.load(URL)
for each x in xml.documentElement.childNodes
if x.NodeName = "latitude" then
T2 = x.text
end if 
if x.NodeName = "longitude" then
T3 = x.text
end if
next
Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Location Of IP Address"
objMessage.Sender = Result2 
objMessage.To = Result2 
objMessage.TextBody = Result1 & VbCrLf & VbCrLf & "Mapquest" & VbCrLf  &  "http://www.mapquest.com/maps/map.adp?searchtype=address&formtype=address&latlongtype=decimal&latitude=" & T2 & "&longitude=" & T3 & VbCrLf & VbCrLf & "GlobeXplorer" & VbCrLf & "http://imageatlas.globexplorer.com/ImageAtlas/view.do?group=ImageAtlas&lat=" & T2 & "&lon=" & T3 & "&zoom_level=10" & VbCrLf & VbCrLf & "Terraserver" & VbCrLf & "http://www.terraserver-usa.com/addressimage.aspx?t=1&s=10&Lon=" & T3 & "&Lat=" & T2 & VbCrLf & VbCrLf & "MapServer" & VbCrLf & "http://mapserver.maptech.com/bp/mapserver/index.cfm?lat=" & T2 & "&lon=" & T3 & "&type=1&scale=250000&zoom=100"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = result3
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
</code>

I want to get this standalone script to work and I can do the rest to make it work correctly with cells etc. If you save it as test.vbs that will let you test it out of excel
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Watch MrExcel Video

Forum statistics

Threads
1,122,334
Messages
5,595,567
Members
413,996
Latest member
mabelO

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top