본문 바로가기
개발자 커뮤니티에 오신 것을 환영합니다!

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

페이지 정보

profile_image
작성자 하나를하더라도최선을
댓글 0건 조회 25,840회 작성일 20-04-10 01:02

본문

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
 

댓글목록

등록된 댓글이 없습니다.


Copyright © program1472 | IT HUB. All rights reserved.