'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 'Private Declare Function URLDownloadToFileW Lib "urlmon" (ByVal pCaller As IUnknown, ByVal szURL As OLE_HANDLE, ByVal szFileName As OLE_HANDLE, ByVal dwReserved As Long, ByVal lpfnCB As OLE_HANDLE) As Long Private Sub Test() 'URLDownloadToFileW Nothing, StrPtr("https://cyberjapandata.gsi.go.jp/xyz/relief/6/56/25.png"), StrPtr("D:\6_56_25.png"), 0, 0 ' wiaaut.dll を参照設定しておく ' Microsoft Windows Image Acquisition Library v2.0 ' Dim objIF As WIA.ImageFile Set objIF = New WIA.ImageFile objIF.LoadFile "D:\6_56_25.png" 'Set UserForm1.Picture = objIF.FileData.Picture 'UserForm1.Show Dim h As Long, w As Long h = objIF.Height w = objIF.Width Dim vnt As Variant, rng As Excel.Range Set rng = Sheet1.Range("A1", Sheet1.Cells(h, w)) vnt = rng.Value Dim vec As WIA.Vector Set vec = objIF.ARGBData Dim x As Long, y As Long For y = 1 To h For x = 1 To w vnt(y, x) = Right("00000000" & Hex(vec.Item(x + (y - 1) * w)), 8) Next Next rng.Value = vnt End Sub