vba PowerPoint 2013 中的 Shape.Height 和 Shape.Width 问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16537022/
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 21:05:49  来源:igfitidea点击:

Shape.Height and Shape.Width problems in PowerPoint 2013

vbapowerpointpowerpoint-vbaoffice-2013

提问by Salil Taneja

I am using a small VBA script to apply some text in the background. The script works fine on PowerPoint 2007 and PowerPoint 2010.

我正在使用一个小的 VBA 脚本在背景中应用一些文本。该脚本在 PowerPoint 2007 和 PowerPoint 2010 上运行良好。

However, in PowerPoint 2013, setting Shape.Height and Shape.Width has no effect. Here is the snippet of the code. Any help would be appreciated.

但是,在 PowerPoint 2013 中,设置 Shape.Height 和 Shape.Width 不起作用。这是代码的片段。任何帮助,将不胜感激。

Public Sub applyWatermark()

Dim curDesign As Design
Set curDesign = ActivePresentation.Designs.Item(1)
Dim masterSlide As Master
Set masterSlide = curDesign.SlideMaster

Dim shape As shape
Set shape = masterSlide.Shapes.AddTextbox(msoShapeRectangle, 0#, 0#, 100#, 100#)

shape.TextEffect.Text = "Watermark"

' Setting height and width works fine on PPT 2010 but does not work on PPT 2013
shape.Height = 200
shape.Width = 300

shape.TextFrame2.WordWrap = msoTrue
shape.TextFrame2.WarpFormat = msoWarpFormat1
shape.Left = 200
shape.Top = 200

End Sub

采纳答案by Salil Taneja

This is an issue with PowerPoint 2013.

这是 PowerPoint 2013 的问题。

Workaround is to set

解决方法是设置

Myshape.TextFrame2.WarpFormat = msoWarpFormat37

Workaround is provided at http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/2c1cf339-aa90-4d82-9475-0ff5f49ac1b1/.

http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/2c1cf339-aa90-4d82-9475-0ff5f49ac1b1/提供了解决方法。

回答by Salil Taneja

I believe this is a known limitation to the MS development team - in some instances it just doesn't fire correctly. One suggestion is to change the font size instead, but that doesn't help much if you actually need a specific font size in the shape.

我相信这是 MS 开发团队的一个已知限制——在某些情况下,它只是不能正确触发。一个建议是改为更改字体大小,但如果您确实需要形状中的特定字体大小,那将无济于事。