1

我在 ppt 中创建了一个宏来插入一个带有明年日期的文本框,因为内置的插入日期仅适用于当年:

Sub displaynextyear()

present = Year(Date)

ActivePresentation.Slides(3).Shapes.AddShape _
(Type:=msoTextOrientationHorizontal, Left:=500, Top:=150, Width:=100, Height:=25) _
.TextFrame.TextRange.Text = "{" & present + 1 & "}"

End Sub

它可以工作,但我想对其进行微调,使其与幻灯片的背景颜色、字体大小等相匹配。每次我尝试插入可能的格式参数时,都会收到错误消息。请问如何自定义?每当打开 ppt 演示文稿时,我如何让它自动运行?

谢谢!约翰

4

1 回答 1

0

The .Background method makes a shapes background match that of its slide.

Sub displaynextyear()
    Dim shp As Shape

    present = Year(Date)

    Set shp = ActivePresentation.Slides(3).Shapes.AddShape _
    (Type:=msoTextOrientationHorizontal, Left:=500, Top:=150, Width:=100, Height:=25)
    shp.TextFrame.TextRange.Text = "{" & present + 1 & "}"

    shp.TextFrame.TextRange.Font.Size = 20
    shp.Fill.Background     'match the slide background

End Sub

This works in PowerPoint 2010, so most likely in PPt 2007 as well.

Note: We cannot record macros in PPt 2010 to help find methods/properties.

于 2013-06-24T20:23:55.913 回答