我正在尝试创建一个命令以在 PowerPoint 中自动导出 PDF。
我有一个粘贴有效照片的命令。但是,它只是粘贴到屏幕的左上角。
我一直在网上寻找一个与幻灯片中心对齐并拉伸(stretch)以适合幻灯片页面的脚本。我尝试录制,但 PowerPoint 好像没有录制功能。
这是我的复制+粘贴脚本,可以在下面运行。
Sub PastePhoto()
Dim Sld As Slide
'Ensure focus is on slide
Application.ActiveWindow.Panes(2).Activate
Set Sld = Application.ActiveWindow.View.Slide
On Error GoTo NoCopy
Sld.Shapes.PasteSpecial (ppPasteEnhancedMetafile)
On Error GoTo 0
Exit Sub
NoCopy:
MsgBox "There was nothing copied to paste!"
最佳答案
这应该是在幻灯片中插入图片并将其拉伸(stretch)以适合幻灯片宽度所需的全部内容:
' Get the first slide...
Dim sl As Slide
Set sl = ActivePresentation.Slides(1)
' Insert a picture at (0, 0)...
Dim sh As Shape
Set sh = sl.Shapes.AddPicture("c:\path\to\my.jpg", msoFalse, msoTrue, 0, 0)
' Set the picture's width to that of a slide...
sh.Width = ActivePresentation.PageSetup.SlideWidth
如果你想将其垂直居中:
sh.Top = (ActivePresentation.PageSetup.SlideHeight - sh.Height) / 2
关于vba - PowerPoint VBA : Copy and paste image, 对齐到中心,并拉伸(stretch)以适合页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32280782/