Private Declare PtrSafe Function URLDownloadToFileW Lib "urlmon" (ByVal pCaller As IUnknown, ByVal szURL As LongPtr, ByVal szFileName As LongPtr, ByVal dwReserved As Long, ByVal lpfnCB As LongPtr) As Long Sub maintest() Dim fol As String Dim 緯度min As Double Dim 緯度max As Double Dim 経度min As Double Dim 経度max As Double 緯度min = 23.998297 緯度max = 46.328724 経度min = 125.683591 経度max = 150.257812 fol = "C:\Users\Y2\Desktop\ファイルフォルダー\" t = Now() Call dl(fol, 経度min, 経度max, 緯度max, 緯度min) MsgBox t & "-" & Now() End Sub Sub dl(fol As String, 経度min As Double, 経度max As Double, 緯度max As Double, 緯度min As Double) Dim i As Long Dim xタイルmin As Long Dim xタイルmax As Long Dim yタイルmin As Long Dim yタイルmax As Long xタイルmin = xタイル(6, 緯度max, 経度min) xタイルmax = xタイル(6, 緯度min, 経度max) yタイルmin = yタイル(6, 緯度max, 経度min) yタイルmax = yタイル(6, 緯度min, 経度max) i = 1 For y = yタイルmin To yタイルmax For x = xタイルmin To xタイルmax URLDownloadToFileW Nothing, StrPtr("https://cyberjapandata.gsi.go.jp/xyz/relief/6/" & x & "/" & y & ".png"), StrPtr(fol & Right("00" & i, 2) & ".png"), 0, 0 i = i + 1 Next Next Call test4WIAタイル3(xタイルmax - xタイルmin + 1, yタイルmax - yタイルmin + 1, fol) End Sub Sub test4WIAタイル3(x As Long, y As Long, fol As String) ' wiaaut.dll を参照設定しておく ' Microsoft Windows Image Acquisition Library v2.0 ' Dim objIF() As WIA.ImageFile Dim h() As Long Dim w() As Long Dim vec() As WIA.vector ReDim objIF(1 To x, 1 To y) ReDim h(1 To x, 1 To y) ReDim w(1 To x, 1 To y) ReDim vec(1 To x, 1 To y) 'https://www.relief.jp/docs/excel-vba-redim-2d-array.html Dim vecT As WIA.vector Dim yc As Long Dim xc As Long Dim yH As Long Dim xW As Long Dim xx As Long Dim st As String For yc = 1 To y For xc = 1 To x Set objIF(xc, yc) = New WIA.ImageFile st = fol & Right("00" & (xc + (yc - 1) * x), 2) & ".png" objIF(xc, yc).LoadFile st h(xc, yc) = objIF(xc, yc).Height w(xc, yc) = objIF(xc, yc).Width Set vec(xc, yc) = objIF(xc, yc).ARGBData Next Next Set vecT = objIF(1, 1).ARGBData vecT.Clear For yH = 1 To y For yy = 1 To h(1, 1) For xW = 1 To x For xx = 1 To w(1, 1) vecT.Add vec(xW, yH).Item(xx + (yy - 1) * w(1, 1)) Next Next Next Next Dim objIFnew As WIA.ImageFile Set oIFNew = vecT.ImageFile(w(1, 1) * x, h(1, 1) * y) oIFNew.SaveFile fol & "0T(" & x & "," & y & ")" & (x * y) & ".png" End Sub