A
Alexcamp
Hello all,
Using the modified code below that was obtained from the thread at
http://www.accessmonster.com/Uwe/Fo...ess/39625/Live-exchange-rate-data-into-Access , I got it to work fine, but only in access 2007. When I open my
form in Access2003, the function will return 0 instead of the desired rate.
Does anyone know why?
Thanks
Public Function exchangeRate2#()
Dim xmlHttpRequest As Object
Dim rawHTML$
Dim regularExpression As Object
Dim matches As Object
Dim match As Object
On Error Resume Next
'will return zero on error
' class and server names may have to be modified
' download available at
' http://www.microsoft.com/downloads/...CF-3BCF-4009-BE21-27E85E1857B1&displaylang=en
Set xmlHttpRequest = CreateObject("MSXML2.XMLHTTP.6.0")
With xmlHttpRequest
.Open "GET", "http://www.bloomberg.com/markets/currencies/fxc.html", False
.send
rawHTML = .responseText
End With
Set regularExpression = CreateObject("VBScript.RegExp")
With regularExpression
.pattern = "CAD<\/span><\/td><td bgcolor=" & Chr$(34) & "white" & Chr$(34)
& " align=" & Chr$(34) & "right" & Chr$(34) _
& "><span class=" & Chr$(34) & "style5" & Chr$(34) & ">(\d\.\d{0,4})<\
/span><\/td><td bgcolor=" & Chr$(34) & "white" & Chr$(34) & " align=" & Chr$
(34) & "right" & Chr$(34) _
& "><span class=" & Chr$(34) & "style5" & Chr$(34) & ">(\d\.\d{0,4})<\
/span><\/td>"
.pattern = Replace(.pattern, Chr$(34), "\" & Chr$(34))
.ignoreCase = True
Set matches = .Execute(rawHTML)
Set match = matches(0)
exchangeRate2 = match.SubMatches(0) + 0.006
End With
Using the modified code below that was obtained from the thread at
http://www.accessmonster.com/Uwe/Fo...ess/39625/Live-exchange-rate-data-into-Access , I got it to work fine, but only in access 2007. When I open my
form in Access2003, the function will return 0 instead of the desired rate.
Does anyone know why?
Thanks
Public Function exchangeRate2#()
Dim xmlHttpRequest As Object
Dim rawHTML$
Dim regularExpression As Object
Dim matches As Object
Dim match As Object
On Error Resume Next
'will return zero on error
' class and server names may have to be modified
' download available at
' http://www.microsoft.com/downloads/...CF-3BCF-4009-BE21-27E85E1857B1&displaylang=en
Set xmlHttpRequest = CreateObject("MSXML2.XMLHTTP.6.0")
With xmlHttpRequest
.Open "GET", "http://www.bloomberg.com/markets/currencies/fxc.html", False
.send
rawHTML = .responseText
End With
Set regularExpression = CreateObject("VBScript.RegExp")
With regularExpression
.pattern = "CAD<\/span><\/td><td bgcolor=" & Chr$(34) & "white" & Chr$(34)
& " align=" & Chr$(34) & "right" & Chr$(34) _
& "><span class=" & Chr$(34) & "style5" & Chr$(34) & ">(\d\.\d{0,4})<\
/span><\/td><td bgcolor=" & Chr$(34) & "white" & Chr$(34) & " align=" & Chr$
(34) & "right" & Chr$(34) _
& "><span class=" & Chr$(34) & "style5" & Chr$(34) & ">(\d\.\d{0,4})<\
/span><\/td>"
.pattern = Replace(.pattern, Chr$(34), "\" & Chr$(34))
.ignoreCase = True
Set matches = .Execute(rawHTML)
Set match = matches(0)
exchangeRate2 = match.SubMatches(0) + 0.006
End With