如何在 excel 中的 powerpoint 中使用 vba 向下移动图像?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7520234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 14:04:57  来源:igfitidea点击:

How to move image down using vba in powerpoint from excel?

vbapowerpoint

提问by thedeepfield

I am new to vba and macros in powerpoint.. What is the correct syntax to position an image down -30?

我是 PowerPoint 中的 vba 和宏的新手。将图像定位到 -30 的正确语法是什么?

PPT.ActiveWindow.View.GotoSlide 9

Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
' Reference active slide
Set PPSlide = PPPres.Slides _
    (PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
' Copy chart as a picture
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, _
    Format:=xlPicture
' Paste chart
PPSlide.Shapes.Paste.Select
' Align pasted chart

Dim xyz As Shape
Set xyz = PPSlide.Shapes.Selection


PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
xyz.Top = xyz.Top - 30

回答by PaulStock

UPDATED

更新

Based on your code sample, I think you want to try something like this:

根据您的代码示例,我认为您想尝试这样的事情:

 PPSlide.Shapes.Paste.Select
' Align pasted chart

PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
PPApp.ActiveWindow.Selection.ShapeRange(1).Top = PPApp.ActiveWindow.Selection.ShapeRange(1).Top + 30

You can take out the lines referring to xyz.

您可以取出引用 xyz 的行。