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