티스토리 뷰

Function DownloadFromURL(FileUrl As String, NewFullName As String) As String
    Dim oXMLHTTP As Object
    Dim oStream As Object

    DownloadFromURL = vbNullString

    If NewFullName = "" Or Dir(NewFullName) <> "" Then Exit Function
    
    Set oXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    
    On Error Resume Next
    oXMLHTTP.Open "GET", FileUrl, False
    oXMLHTTP.send
    On Error GoTo 0

    If oXMLHTTP.Status <> 200 Then Exit Function
    
    Set oStream = CreateObject("ADODB.Stream")

    On Error Resume Next
    oStream.Open
    oStream.Type = 1
    oStream.Write oXMLHTTP.responseBody
    oStream.SaveToFile NewFullName, 2
    oStream.Close
    On Error GoTo 0

    If Err.Number = 0 Then DownloadFromURL = NewFullName

    Set oXMLHTTP = Nothing
    Set oStream = Nothing
End Function

이전 다운로드 코드는 일부 컴퓨터에서 안되는 문제가 발생되어 코드 변경하였습니다

아직 안된다던 컴퓨터에서 테스트 전입니다