Boa tarde Amigos
Como capturar o valor do cambio do Metical no campo do formulário desta BD.
Como capturar o valor do cambio do Metical no campo do formulário desta BD.
Function CotacaoMZN() As String
'ahteixeira 2018 para MaximoAccess
Dim objIE As Object, objTb As Object
Dim i As Integer, intPos As Integer
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False
objIE.Navigate "https://cotacao-euro.pt/cambio/MZN-metical-mocambique/"
Do While objIE.Busy: DoEvents: Loop
Do While objIE.ReadyState <> 4: DoEvents: Loop
For i = 0 To objIE.Document.all.length - 1
Set objTb = objIE.Document.all.Item(i)
intPos = InStr(objTb.innerHTML, "1 MZN = ")
If intPos > 0 Then
CotacaoMZN = Mid(objTb.innerHTML, intPos + 8, 6)
Exit For
End If
Next
objIE.Quit
Set objIE = Nothing
End Function
Private Sub CmdConsultar_Click()
'ahteixeira 2018 para MaximoAccess
'Requer função CotacaoMZNv2
Dim strMZN As String
Dim intPos As Integer
Me.CmdConsultar.Caption = "Aguarde por favor"
strMZN = CotacaoMZNv2
intPos = InStr(strMZN, "1 MZN = ")
Me.Valorcotacao = Mid(strMZN, intPos + 8, 6)
intPos = InStrRev(strMZN, ",")
Me.DataCotacao = CDate(Replace(Trim(Mid(strMZN, intPos + 2, 8)), ".", "/"))
Me.CmdConsultar.Caption = "Consultar cotação online"
End Sub
Function CotacaoMZNv2() As String
'ahteixeira 2018 para MaximoAccess
Dim objIE As Object
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False
objIE.Navigate "https://cotacao-euro.pt/cambio/MZN-metical-mocambique/"
Do While objIE.Busy: DoEvents: Loop
Do While objIE.ReadyState <> 4: DoEvents: Loop
CotacaoMZNv2 = objIE.Document.getElementById("kurzInfo").innerText
objIE.Quit
Set objIE = Nothing
End Function