使用Powerpoint VBA调整图片大小 [英] Resizing picture using Powerpoint vba
问题描述
我正在尝试使用powerpoint vba调整从Excel粘贴到powerpoint中的图片的大小.
I am trying to resize a picture that I have pasted into powerpoint from Excel using powerpoint vba.
我的代码说:
ActivePresentation.Slides(9).Select
Application.ActiveWindow.View.PasteSpecial DataType:=ppPasteEnhancedMetafile
ActivePresentation.Slides(9).Select
Application.ActiveWindow.View.PasteSpecial DataType:=ppPasteEnhancedMetafile
这部分效果很好,我不知道如何在下一步中调整图片的大小.我是使用Powerpoint VBA的新手.
This part works fine, I am at a loss as how to then resize the picture in the next step. I am new to using powerpoint vba.
任何帮助将不胜感激.
推荐答案
-
请不要选择任何东西,除非您绝对必须,而且很少需要..而是获取对形状的引用.
Never select anything unless you absolutely must, and you very rarely must.. Get a reference to the shape instead.
您实际上不需要查看幻灯片来操纵幻灯片上的形状
You don't actually need to be viewing a slide to manipulate the shapes ON that slide
使用形状的.Top,.Left,.Height和.Width属性设置其位置和大小
Use the shape's .Top, .Left, .Height and .Width properties to set its position and size
示例:
Dim oSh As Shape Set oSh = ActivePresentation.Slides(9).Shapes.PasteSpecial(ppPasteEnhancedMetafile)(1) ' .PasteSpecial returns a ShapeRange; the (1) at the end of the line above ' returns the first shape in the range. W/o that, you get a type mismatch error ' from trying to assign a range to a shape With oSh ' Set position: .Left = 0 .Top = 0 ' Set size: .Height = 100 .Width = 200 End With
这篇关于使用Powerpoint VBA调整图片大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!