【问题标题】:VBA code to adjust image size in PowerPoint 2016在 PowerPoint 2016 中调整图像大小的 VBA 代码
【发布时间】:2018-11-23 11:11:25
【问题描述】:

我在学习 VBA 的第一周,我正在寻找一个 VBA 代码,它可以帮助我调整粘贴到 PowerPoint 2016 中的图片的大小和位置。所需的图片格式详细信息如下:

尺寸
- 高度 = 3.39 英寸
- 宽度 = 6.67 英寸
- 旋转 = 0
- 比例高度 = 62%
- 比例宽度 = 62%
- 纵横比 = 锁定
- 相对于原始图片大小 = true

位置
- 水平位置 = 0
- 左上角
- 垂直位置 = 2.06
- 左上角

任何帮助将不胜感激。

【问题讨论】:

    标签: vba image-resizing powerpoint-2016


    【解决方案1】:

    以下是对我有用的代码。感谢您的支持。

    Sub ResizeAll()
    For Each tSlide In ActiveWindow.Presentation.Slides
        tSlide.Select
        With tSlide.Shapes.Item(1)
        'assume a blank slide with one image added only
            .Select
            .Height = 72 * 3.39
            .Width = 72 * 6.67
        'algin middle (Horizontal Center)
            .Left = 0
            .Top = ActivePresentation.PageSetup.SlideHeight / 3.25
        End With
    Next
    End Sub
    

    【讨论】:

    • 虽然不需要删除两个 .Select 语句,但它们都不是必需的,没有它们,您的代码将运行得更快。
    【解决方案2】:

    好的,所以这个宏会调整你的PowerPoint中每张图片的细节。

    Sub AdjustImages()
    
        Dim curSlide As Slide
        Dim curShape As Shape
    
        For Each curSlide In ActivePresentation.Slides
            For Each curShape In curSlide.Shapes
                With curShape
    
                    'size:
                    ''1 inch = 72 points
                    .Height = 72 * 3.39
                    .Width = 72 * 6.67
    
                    .ScaleHeight 0.62, msoTrue
                    .ScaleWidth 0.62, msoTrue
    
                    .LockAspectRatio = msoTrue
    
    
                    'position:
                    .Rotation = 0
    
                    .Left = 0
                    .Top = 2.06
    
                    'Relative to original picture size = true
    
                End With
            Next curShape
        Next curSlide
    
    End Sub
    

    您的问题中唯一我不明白的部分是当您提到它“相对于原始图片大小 = true”时。我似乎找不到与之匹配的属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-25
      • 1970-01-01
      • 2013-05-20
      相关资源
      最近更新 更多