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