【環境】
mac
Excel 2016
Excel上に画像URLが縦に並んでいるとします。(http://〜)
その横にURLにアクセスすると表示される画像を貼り付ける事は可能でしょうか?
lang
1ActiveSheet.Pictures.Insert("{画像URL}").Select
を使用してみたのですが、
実行時エラー '1004':
Pictures クラスの Insert プロパティを取得できません。
と表示されました。
現状この方法では貼り付ける事は出来ないのでしょうか?
※追記
以下の方法で画像の貼り付けは出来たのですが、
画像のサイズがセルのサイズとなってしまい、縦横比率がおかしくなってしまいます。
縦横比率を保つようにする事は可能なのでしょうか?
lang
1Private Declare Function URLDownloadToFile Lib "urlmon" Alias _ 2"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _ 3szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long 4 5Sub PicDownLoad() 6Dim strFname As String, strUrl As String 7Dim retValue As Long, i As Long 8Dim endRow As Long 9endRow = Cells(Rows.Count, 1).End(xlUp).Row 10For i = 1 To endRow 11strUrl = Cells(i, 1).Text 12If strUrl <> "" Then 13strFname = "D:\rinji\" & Mid(strUrl, InStrRev(strUrl, "/") + 1) 14retValue = URLDownloadToFile(0, strUrl, strFname, 0, 0) 15If retValu = 0 Then 16With Cells(i, 2) 17Set objShape = ActiveSheet.Shapes.AddPicture( _ 18Filename:=strFname, LinkToFile:=False, _ 19SaveWithDocument:=True, Left:=.Left, _ 20Top:=.Top, Width:=.Width, Height:=.Height) 21End With 22Else 23MsgBox "DownLoad Fail " & Chr(10) & strUrl 24End If 25End If 26Next i 27End Sub

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。