Hi, I use the code below to download an xml-file to a local folder and then I read it and use data...
The issue is that I cannot use the code on MACs, since the needed references are missing...
Pls. advise!
Thank you.
-------------------------
VBA Module:
-------------------------
Option Explicit
Option Private Module
'a reference to Microsoft XML 6.0 is mandatory
Public Sub GetFxFile(yr As Integer)
'define local variables and objects
Dim reader As New XMLHTTP60
Dim doc As DOMDocument60
'initialize the reader
reader.Open "GET", "Eroare/ Error" & Format(yr, "#") & ".xml", False
reader.setRequestHeader "Accept", "application/xml"
reader.send
Do Until reader.ReadyState = 4
DoEvents
Loop
'initialize the current workbook's path..
xPath = ThisWorkbook.Path
'check for reader's status
If reader.Status = 200 Then
Set doc = reader.responseXML
'save the xml file
If Application.OperatingSystem Like "Windows*" Then
doc.Save xPath & "\CursBNR.xml"
Else
doc.Save xPath & "/CursBNR.xml"
End If
Else
'inform the user
MsgBox "Missing file for target year...", vbOKOnly + vbExclamation + vbSystemModal, pName
'update data reference
dataRef = False
End If
End Sub
The issue is that I cannot use the code on MACs, since the needed references are missing...
Pls. advise!
Thank you.
-------------------------
VBA Module:
-------------------------
Option Explicit
Option Private Module
'a reference to Microsoft XML 6.0 is mandatory
Public Sub GetFxFile(yr As Integer)
'define local variables and objects
Dim reader As New XMLHTTP60
Dim doc As DOMDocument60
'initialize the reader
reader.Open "GET", "Eroare/ Error" & Format(yr, "#") & ".xml", False
reader.setRequestHeader "Accept", "application/xml"
reader.send
Do Until reader.ReadyState = 4
DoEvents
Loop
'initialize the current workbook's path..
xPath = ThisWorkbook.Path
'check for reader's status
If reader.Status = 200 Then
Set doc = reader.responseXML
'save the xml file
If Application.OperatingSystem Like "Windows*" Then
doc.Save xPath & "\CursBNR.xml"
Else
doc.Save xPath & "/CursBNR.xml"
End If
Else
'inform the user
MsgBox "Missing file for target year...", vbOKOnly + vbExclamation + vbSystemModal, pName
'update data reference
dataRef = False
End If
End Sub