2
我試圖將Google街景視圖嵌入到Excel中。我發現這個link它有下面的代碼。對我來說根本不起作用,並尋找一些幫助開始。顯然,我需要設置變量來查找街景網址。但我從來沒有通過VBA插入圖片,尋找一些指導。將Google街景視圖圖像嵌入到Excel中
Sub GoogleStaticStreetView(oShape As Shape, _
sAddress As String, _
lHeading As Long, _
Optional lHeight As Long = 512, _
Optional lWidth As Long = 512)
'https://developers.google.com/maps/documentation/streetview/
Dim sURL As String
Dim sMapsURL As String
On Error GoTo RETURN_FALSE
If bRunMode Then On Error Resume Next 'Error if quota exceeded
If Len(sAddress) > 0 Then
'URL-Escaped addresses
sAddress = Replace(sAddress, " ", "+")
Else
Exit Sub
End If
sURL = _
"http://maps.googleapis.com/maps/api/streetview?" & _
"&location=" & sAddress & _
"&size=" & lWidth & "x" & lHeight & _
"&heading=" & lHeading & _
"&sensor=false"
sMapsURL = "http://maps.google.com/maps?q=" & _
sAddress & "&t=m&layer=c&panoid=0" & _
"&cbp=12," & lHeading & ",,0,4.18"
oShape.Fill.UserPicture sURL
oShape.AlternativeText = sMapsURL
Exit Sub
RETURN_FALSE:
End Sub
Sub GoogleStaticMap(oShape As Shape, _
sAddress As String, _
Optional sMapType As String = "roadmap", _
Optional lZoom As Long = 12, _
Optional lHeight As Long = 512, _
Optional lWidth As Long = 512)
'https://developers.google.com/maps/documentation/staticmaps/
Dim sURL As String
Dim sMapsURL As String
Dim sMapTypeURL As String
On Error GoTo RETURN_FALSE
' Google Maps Parameters '&t=m' = roadmap, '&t=k' = satellite
sMapTypeURL = "m"
If sMapType = "satellite" Then
sMapTypeURL = "k"
End If
If bRunMode Then On Error Resume Next 'Error if quota exceeded
If Len(sAddress) > 0 Then
'URL-Escaped addresses
sAddress = Replace(sAddress, " ", "+")
Else
Exit Sub
End If
sURL = _
"http://maps.googleapis.com/maps/api/staticmap?center=" & _
sAddress & "," & _
"&maptype=" & sMapType & _
"&markers=color:green%7Clabel:%7C" & sAddress & _
"&zoom=" & lZoom & _
"&size=" & lWidth & "x" & lHeight & _
"&sensor=false" & _
"&scale=1"
sMapsURL = "http://maps.google.com/maps?q=" & _
sAddress & _
"&z=" & lZoom & _
"&t=" & sMapTypeURL
oShape.Fill.UserPicture sURL
oShape.AlternativeText = sMapsURL
Exit Sub
RETURN_FALSE:
End Sub
太棒了!我的代表並不是15,以支持你。第二個是我會給你你應得的道具! 一個後續問題: The Sheets(1)。 Shapes.Delete正在踢出一個錯誤。我試過Sheet.Sheet1.Shapes.Delete,但它也不那麼喜歡。我們不應該確定我們正在清除圖像的哪張紙嗎? – user5469188
道歉這麼晚纔回復,儘量activesheet而不是紙板(1) –
使用這個工作非常出色的: 昏暗的小水電爲形狀 對於每個SHP在ActiveSheet.Shapes Shp.Delete 接下來SHP – user5469188