答案1
这不是一个可行的操作。
VBA可以调用系统的截屏工具,但是我们无法在网页中控制截屏工具并粘贴到ppt中。
答案2
虽然从 VBA 执行整个操作可能不可行,但类似这样的操作可以消除大部分繁琐的工作。您可以手动制作屏幕截图,然后调用宏将新幻灯片添加到当前演示文稿中,粘贴屏幕截图,设置其格式,添加标题等等:
Option Explicit
' Edit these as required:
Const lLayoutType As Long = 6 ' 6=TitleOnly, 7=Blank
Const lFontSize As Long = 16 ' Font size of slide title, if any
Const sngCropTop As Single = 142
Sub PasteMap()
' Assumes map has been Alt+PrtScreen'ed from a fullscreen window in Chrome
' from Google Maps
Dim oSl As Slide
Dim oSh As Shape
Dim sTemp As String
sTemp = "Type title here"
With ActivePresentation
' add a new slide
Set oSl = .Slides.AddSlide(.Slides.Count + 1, .Designs(1).SlideMaster.CustomLayouts(lLayoutType))
' paste in the screenshot
Set oSh = oSl.Shapes.Paste(1)
' format the pasted screenshot:
With oSh
' prevent it from being distorted by size changes
.LockAspectRatio = True
' set it to the width of the slide
.Width = ActivePresentation.PageSetup.SlideWidth
' crop off the top by a pre-determined amount (see beginning of code)
.PictureFormat.CropTop = sngCropTop
' move it to the left of the slide
.Left = 0
' position it appropriately from top of slide
.Top = ActivePresentation.PageSetup.SlideHeight - .Height
End With
' get a title for the map, set and position the title
On Error Resume Next ' won't work if no title in the layout!
Set oSh = oSl.Shapes(1) ' the title
oSh.Top = 5
oSh.TextFrame.VerticalAnchor = msoAnchorTop
With oSh.TextFrame.TextRange
.Font.Size = lFontSize
sTemp = InputBox("Page title:", "Page title", sTemp)
If Len(sTemp) > 0 Then
.Text = sTemp
End If
End With
End With
End Sub