VBA POWERPOINT:从POWERPOINT中收缩Word图片
当我在word宏中使用此函数将所有图像缩小到9.3cm时,此函数起作用:VBA POWERPOINT:从POWERPOINT中收缩Word图片,vba,ms-word,powerpoint,Vba,Ms Word,Powerpoint,当我在word宏中使用此函数将所有图像缩小到9.3cm时,此函数起作用: 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宏中运行它
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改成变体,但没用
编辑:因此我现在确定,在powerpoint中,厘米点(9.3)返回0,而在Word中返回263左右。现在就开始研究吧。我刚刚制定了自己的方法……而且很有效
Function CmToPt(pt As Single) As Single
CmToPt = pt * 28.35
End Function
不知道为什么正常的方法不起作用,但这确实起到了作用。在PowerPoint中,没有什么能比得上你在这种情况下调用的
厘米停止点。您需要引用Word对象变量来获取维度。也许是这样:
Sub CentimetersTo_Word()
Dim WRD As Object
Set WRD = CreateObject("Word.Application")
Debug.Print WRD.centimeterstopoints(10)
End Sub
因此,只需在cmistopoint