vb6.0/vba [vb6.0/vba] vba 바탕화면의 특정폴더에 파일 다운로드
페이지 정보
본문
Sub download_Files_From_Web()
Dim C As Range
Dim strPath As String
Dim filename As String
strPath = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\ABC\"
If Len(Dir(strPath, vbDirectory)) = 0 Then MkDir strPath
If Len(Dir(strPath, vbDirectory)) = 0 Then
MsgBox "폴더를 생성할 수 없습니다."
End
End If
For Each C In ActiveSheet.UsedRange
If InStr(C, "http") Then
filename = C.Next & "." & Split(C, ".")(UBound(Split(C, ".")))
DownloadFile C.Value, strPath, filename
End If
Next
MsgBox "End."
End Sub
Function DownloadFile(url As String, DownloadPath As String, filename As String)
Dim Buf() As Byte, FN As Integer
DownloadPath = IIf(Right(DownloadPath, 1) = "\", Left(DownloadPath, Len(DownloadPath) - 1), DownloadPath)
DownloadPath = DownloadPath & "\" & filename
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", url, 0
.send
Buf = .responsebody
End With
FN = FreeFile()
Open DownloadPath For Binary Access Write As #FN
Put #FN, , Buf
Close #FN
End Function
- 이전글[vba] 엑셀(Excel) 셀 오른쪽 마우스 매뉴 20.03.17
- 다음글[vb6.0/vba] 웹브라우져(InternetExplorer)를 이용한 다음 지도검색 20.03.16
댓글목록
등록된 댓글이 없습니다.