我用一个小的子程序通过VBA擅长形状
ActiveSheet.Pictures.Insert(URL).Select
能正常工作与Excel 2003(Windows)中插入图片到我的表,但不与Excel 2011(苹果机)工作了。
所以我修改 (如提出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
任何建议或提示?也许我是盲目的蝙蝠....
你确定你所引用的URL实际上是一个图片吗?我使用的是Excel 2010(Windows),但是您的子工作正常(我使用了一个示例Google Maps URL)。我会看看'URL'的值。您可能有畸形的链接。 – Zairja 2012-08-07 18:58:48
感谢您的提示。但是URL是好的。我也使用Google API,正如我所提到的,这适用于Excel 2003.我没有更改我的工作表内容。我用给定的URL测试了UserPicture-method,它不起作用。 目前我认为这个问题可能取决于我的MS-Office的设置。任何经验? – TomThumb 2012-08-08 06:10:47
URL和本地文件访问有所不同: 'theShape.Fill.UserPicture“http://maps.googleapis.com/maps/api/streetview?_&location=51.501554,-0.178082&size=512x512&heading=135&fov=100&pitch=0&sensor = false“ 以错误结尾 'theShape.Fill.UserPicture”Macintosh HD:库:用户图片:鲜花:花。tif“' 作品!! – TomThumb 2012-08-08 07:22:12