[vba] WinHttp 파일 다운로드 > vb6.0/vba

본문 바로가기

vb6.0/vba

[vb6.0/vba] [vba] WinHttp 파일 다운로드

회원사진
하나를하더라도최선을
2020-04-10 01:02 3,549 0

본문



Sub program1472_com()
 
    Dim B() As Byte, FN As Long
    Dim URL As String
    Dim filePath As String, FileName As String
    Dim C As Range
    filePath = ThisWorkbook.Path & "\/"
    
    For Each C In Range("A2:A100")
        If InStr(C, "http"= 1 Then
            URL = C.Value
            FileName = Split(URL, "/")(UBound(Split(URL, "/")))
            With CreateObject("WinHTTP.WinHTTPrequest.5.1")
                .Open "GET", URL, False
                .Send
                .WaitForResponse: DoEvents
                '// debug.? .GetAllResponseHeaders
                B = .ResponseBody
            End With
            FN = FreeFile
            Open filePath + FileName For Binary Access Write As #FN
                Put #FN, 1, B
            Close #FN
        End If
    Next
    MsgBox "모든 작업이 완료되었씁니다."
 
End Sub
 

댓글목록0

등록된 댓글이 없습니다.
게시판 전체검색