Aşağıdaki şekilde çözdüm
Private Sub CommandButton2_Click()
On Error GoTo Hata
Dim Http As Object
Dim dosya() As Byte
Dim tarih As String
Dim yol As String
Dim dosyano As Integer
Dim masaustu As String
Dim URL As String
Dim Body As String
tarih = Format(Now, "yyyymmdd_hhnnss")
masaustu = CreateObject("WScript.Shell").SpecialFolders("Desktop")
yol = masaustu & "\Ozelgeler_" & tarih & ".xlsx"
URL = "
"
Body = "{""status"":2,""deleted"":false,""description"":"""",""kanunNo"":"""",""rkType"":99,""title"":"""",""mevzuatType"":""OZELGE""}"
Set Http = CreateObject("MSXML2.XMLHTTP.6.0")
Http.Open "POST", URL, False
Http.setRequestHeader "Content-Type", "application/json"
Http.Send Body
If Http.Status = 200 Then
dosya = Http.responseBody
dosyano = FreeFile
Do While Dir(yol) <> ""
yol = masaustu & "\Ozelgeler_" & tarih & "_" & Format(Timer * 100, "0") & ".xlsx"
Loop
Open yol For Binary Access Write As #dosyano
Put #dosyano, , dosya
Close #dosyano
Workbooks.Open Filename:=yol
MsgBox "Dosya başarıyla indirildi.", vbInformation
Else
MsgBox "Sunucu hatası: " & Http.Status & vbCrLf & Http.responseText
End If
Exit Sub
Hata:
MsgBox "VBA hata: " & Err.Number & vbCrLf & Err.Description
End Sub