Sub UploadFromVBA()
Dim myUserName As String
myUserName = "PUT YOUR RUNSATURDAY USER NAME HERE"
Dim myPassword As String
myPassword = "PUT YOUR PASSWORD HERE"
Dim sportType As String
sportType = "Run" ' One of "Run", "Swim", "Bike", "Walk", "Water", "Winter", "Skate", "Cross"
Dim sportSubType As String
sportSubType = "General" ' put your single word tag here
Dim theTitle As String
theTitle = "My example run" ' title goes here
Dim longNotes As String
longNotes = "Long description" ' note that you really should XML encode this string!
Dim whenStarted As String
whenStarted = "2010-02-15T11:21:13.000Z" ' start time here
Dim durationInSeconds As Double
durationInSeconds = 3412 ' time taken in seconds here
Dim distanceInMetres As Double
distanceInMetres = 10000 ' distance in metres here
Dim calories As Long
calories = 520 ' calories here
Dim intensity As Integer
intensity = 8 ' 0 is unknown, 1->10 is easy->hard
Dim strXML As String
strXML = "<?xml version=""1.0"" encoding=""utf-8""?>"
strXML = strXML & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
strXML = strXML & "<soap:Header>"
strXML = strXML & "<UploadTrackCredentials xmlns=""http://www.runsaturday.com/"">"
strXML = strXML & "<UserName>" & myUserName & "</UserName>"
strXML = strXML & "<SecretKey>" & myPassword & "</SecretKey>"
strXML = strXML & "</UploadTrackCredentials>"
strXML = strXML & "</soap:Header>"
strXML = strXML & "<soap:Body>"
strXML = strXML & "<AddSimpleActivity xmlns=""http://www.runsaturday.com/"" >"
strXML = strXML & "<type>" & sportType & "</type>"
strXML = strXML & "<subType>" & sportSubType & "</subType>"
strXML = strXML & "<title>" & theTitle & "</title>"
strXML = strXML & "<startedAt>" & whenStarted & "</startedAt>"
strXML = strXML & "<distanceInMetres>" & distanceInMetres & "</distanceInMetres>"
strXML = strXML & "<durationInSeconds>" & durationInSeconds & "</durationInSeconds>"
strXML = strXML & "<notes>" & longNotes & "</notes>"
strXML = strXML & "<calories>" & calories & "</calories>"
strXML = strXML & "<intensity>" & intensity & "</intensity>"
strXML = strXML & "</AddSimpleActivity>"
strXML = strXML & "</soap:Body>"
strXML = strXML & "</soap:Envelope>"
Dim objHTTP As New MSXML2.XMLHTTP
objHTTP.Open "post", "http://www.runsaturday.com/runsaturday/ManualSync.asmx"
objHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
objHTTP.setRequestHeader "SOAPAction", "http://www.runsaturday.com/AddSimpleActivity"
objHTTP.send strXML
Dim result As String
result = objHTTP.responseText
Dim AddSimpleActivityResult As Integer
AddSimpleActivityResult = InStr(result, "<AddSimpleActivityResult>")
Dim EndAddSimpleActivityResult As Integer
EndAddSimpleActivityResult = InStr(result, "</AddSimpleActivityResult>")
If AddSimpleActivityResult = 0 Then
MsgBox "Failed"
MsgBox result
Exit Sub
End If
If EndAddSimpleActivityResult = 0 Then
MsgBox "Failed Weirdly"
MsgBox result
Exit Sub
End If
Dim lenOfTag As Integer
lenOfTag = Len("<AddSimpleActivityResult>")
Dim activityId As Long
activityId = CLng(Mid(result, AddSimpleActivityResult + lenOfTag, EndAddSimpleActivityResult - (AddSimpleActivityResult + lenOfTag)))
MsgBox "Activity added at http://www.runsaturday.com/act/" & activityId
End Sub