0

I have coded these few lines below. The code correctly works when I connect through a VPN but no longer works outside VPN. The returned status code is 12007 out VPN and 200 with the VPN.

For example, you can use myUrl : "https://www.boursedirect.fr/fr/marche/euronext-paris/lyxor-ep-na-us-LU1832418856-MUA-EUR-XPAR/seance"

Do you have any idea how to resolve this difficulty?

Public Function InterrogationCours(myUrl) As Double
  Dim avant as String, apres as String, cotation As String

  avant = "quotation-last bd-streaming-select-value-last"
  apres = "</span"

  On Error Resume Next
  With CreateObject("MSXML2.XMLHTTP")
    .Open "GET", myUrl, False
    .Send
    Debug.Print .Status
    If .Status = 200 Then cotation = Split(Split(Split(.responseText, avant)(1), ">")(1), apres)(0)
  End With
  InterrogationCours = Nettoyage(cotation)
End Function
Christophe C.
  • 147
  • 3
  • 13
  • Change `Dim avant, apres, cotation As String` to `Dim avant As String, apres As String, cotation As String` (in VBA you have to declare each element. The way you have it declared, only `cotation` is of data type `String`. Other 2 are of type `Variant`). Maybe that will help. Also, what is `Nettoyage`? – Zac Aug 20 '20 at 08:38
  • @Zac, Thanks for your suggestions. However, they do not solve my problem. As for "Nettoyage", it is about a function which cleans the character string "cotation" to retain only the information which interests me. – Christophe C. Aug 20 '20 at 14:03
  • Is the VPN changing your country? And is your actual country forbidden from viewing the page? – QHarr Aug 20 '20 at 15:59
  • [Error 12007](https://docs.oracle.com/cd/E25293_01/doc.910/e15484/oltappxa.htm) indicates DNS issues. Website shown in Browser? Tried `WinHttp.WinHttpRequest.5.1` instead of `MSXML2.XMLHTTP` – ComputerVersteher Aug 20 '20 at 21:15

0 Answers0