J'utilise "cours-action-boursorama-new.xlsm" qui convient pour les actions simples dont l'url est du type :
www boursorama com/cours/1rPSTM
mais les url du type pour les opcvm:
boursorama com/bourse/opcvm/cours/0P0000YRTT
ou mieux du type historique:
boursorama com/cours/historique/1rPSTM
boursorama com/bourse/opcvm/cours/historique/0P0000YRTT
ne marchent pas !
Le type historique permet de dater et charger la dernière cotation et la variation depuis le dernier cours.*
Merci pour votre aide ! Help!
Le code actuel:
Sub MajCotations()
Dim i%, k%, URL$, COT
k = Cells(Rows.Count, [REF].Column).End(xlUp).Row
Range(Cells(2, [Cotation].Column), Cells(k, [Cotation].Column)).Clear
avant = """price"":"
apres = ","
On Error Resume Next
For i = 2 To k
DoEvents
ReDim COT(1 To k, 1 To 1)
COT(1, 1) = Cells(i, [Cotation].Column).Value
URL = Cells(i, [WWW].Column).Value
Application.StatusBar = "Mise à jour des cotations en cours …"
On Error Resume Next
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, False
.Send
If .Status = 200 Then COT(i, 1) = Split(Split(.responseText, avant)(1), apres)(0)
End With
Application.StatusBar = False
Cells(i, [Cotation].Column).Value = COT(i, 1)
Next
End Sub