【问题标题】:VBA POWERPOINT: Shrink Word pictures from powerpointVBA POWERPOINT:从PowerPoint中缩小Word图片
【发布时间】:2013-04-16 20:59:30
【问题描述】:

当我在 word 宏中使用此功能将所有图像缩小到 9.3 厘米时,此功能起作用:

Sub ShrinkWordImages()
Dim iShp As InlineShape

For Each iShp In ActiveDocument.InlineShapes
    iShp.LockAspectRatio = msoTrue
    iShp.Width = CentimetersToPoints(9.3)
Next iShp

End Sub

但是当我尝试从 powerpoint 宏中运行它时,引用一个 word 文档(所有引用都正确到位),word 文档中的图像就会消失。 从 powerpoint 我用这个,这是唯一的区别:

For Each iShp In wrdDoc.InlineShapes

wrdDoc 已正确声明和设置的位置。

宏完成后,PowerPoint 也会崩溃。 我尝试将 iShp 更改为变体,但没有帮助。

编辑:所以我现在确定 CentimetersToPoints(9.3) 在 powerpoint 中返回 0,而在 Word 中返回 263 左右。现在正在调查。

【问题讨论】:

    标签: vba ms-word powerpoint


    【解决方案1】:

    在 PowerPoint 中没有像 CentimetersToPoint 这样的东西,您可以根据自己的情况调用。您需要参考您的 Word 对象变量来获取维度。可能是这样的:

    Sub CentimetersTo_Word()
    
        Dim WRD As Object
        Set WRD = CreateObject("Word.Application")
    
        Debug.Print WRD.centimeterstopoints(10)
    
    End Sub
    

    因此,只需在 CentimetersToPoint 之前添加您的 Word 应用程序引用

    【讨论】:

      【解决方案2】:

      刚做了我自己的方法……它奏效了。

      Function CmToPt(pt As Single) As Single
      CmToPt = pt * 28.35
      End Function
      

      不知道为什么正常的不能正常工作,但这确实成功了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-13
        • 2013-09-25
        • 2018-02-23
        • 2019-03-20
        • 2016-12-06
        相关资源
        最近更新 更多