我使用了一个小子程序将图片插入到我的工作表中
ActiveSheet.Pictures.Insert(URL).Select
这适用于 Excel 2003 (Windows),但不再适用于 Excel 2011 (Mac)。
因此我修改了我的子程序(如建议的http://www.launchexcel.com/google-maps-excel-demo/),但子程序停在
theShape.Fill.UserPicture URL
带有错误消息
“-2147024894 (80070002) Fehler der Methode UserPicture des Objekts FillFormat”
矩形是绿色的!
Sub Q1()
Dim wks As Worksheet
Dim URL As String
Dim i As Long
Dim lastRow As Long
Dim theShape As Shape
Dim pasteCell As Range
' Used Worksheet
Set wks = Worksheets("Blatt1")
' Delete already existing shapes
For Each theShape In wks.Shapes
theShape.Delete
Next theShape
' Check all existing rows in Column K
lastRow = Cells(Rows.Count, "K").End(xlUp).Row
For i = 2 To lastRow
' the URLs are already computed and stored in column K
URL = wks.Range("K" & i).Value
' try to put the images in column L
Set pasteCell = wks.Range("L" & i)
pasteCell.Select
' Create a Shape for putting the Image into
' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!!
Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200)
' fill the shape with the image after greening
theShape.Fill.BackColor.RGB = RGB(0, 255, 0)
theShape.Fill.UserPicture URL
Next i
End Sub
有什么建议或提示吗?大概我是个瞎子吧……