2013-05-14 143 views
1

我正在使用一個小的VBA腳本在背景中應用一些文本。該腳本在PowerPoint 2007和PowerPoint 2010上正常工作。PowerPoint 2013中的Shape.Height和Shape.Width問題

但是,在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 
+1

您是否嘗試過在「Set shape = masterSlide.Shapes ...」中設置高度和寬度屬性?也許這會更可靠。 – 2013-06-01 01:13:54

+0

我在msdn上發佈了這個問題,並得到了一個解決方法將warpFormat設置爲msoWarpForm37,並且工作。 – 2013-06-04 06:47:38

回答

1

我相信這是MS開發團隊的一個已知限制 - 在某些情況下,它只是不能正確開火。一個建議是改變字體大小,但如果你真的需要一個特定的字體大小的形狀沒有多大幫助。

+1

確實。 '.height'(以及寬度,頂部和左側)是我一直都會遇到這種錯誤的唯一地方,除非您逐步使用F8,否則它們根本不會觸發。我已經在TextBoxes,ChartObject.PlotArea等等上做過這件事......如果我沒有記錯,在大多數情況下,如果選擇了形狀,它會正確設置這些屬性。我討厭'選擇',因爲它通常可以避免,但這是我認爲我需要使用它的一個地方。 – 2013-06-01 01:12:18

+0

Select是一個合適的解決方法 - 我甚至沒有想到這一點。 – Thomas 2013-06-03 15:13:10