In PowerPoint 2010/2013, how to keep watermark always on top using VBA

蹲街弑〆低调 提交于 2019-12-11 07:37:38

问题


I am using a small VBA program to apply some text in the background. I am able to apply watermark but if I use any image in the presentation then the watermark goes behind that image. Is there any way to keep the watermark always in front. I am using this code to apply watermark :

Dim cntDesigns As Integer
cntDesigns = ActivePresentation.Designs.Count

For iter = 1 To cntDesigns
    Dim curDesign As Design
    Set curDesign = ActivePresentation.Designs.Item(iter)

    ' EnumerateMasters
    Dim masterCount As Integer  
    masterCount = 1
    Dim masters(100) As Master
    Set masters(masterCount) = curDesign.SlideMaster

    Dim cntLayouts As Integer
    cntLayouts = curDesign.SlideMaster.CustomLayouts.Count
    For Layout = 1 To cntLayouts
        Dim curLayout As CustomLayout
        Set curLayout = curDesign.SlideMaster.CustomLayouts(Layout)

        If curLayout.DisplayMasterShapes = msoFalse Then
            masterCount = masterCount + 1
            Set masters(masterCount) = curLayout
        End If
    Next Layout

    For masterIter = 1 To masterCount
         Dim shape As shape
        Set shape = masters(masterIter).Shapes.AddTextbox(msoTextOrientationHorizontal, 0#, 0#, 100#, 100#)
        shape.TextEffect.Text = "Watermark"
        shape.Height = 100
        shape.Width = 100
        shape.TextFrame2.WordWrap = msoTrue
        shape.TextFrame2.WarpFormat = msoWarpFormat1
        shape.Left = 100
        shape.Top = 200

    Next masterIter
Next iter

回答1:


No, anything you put on top of something will cover it up. There's no "Keep this shape on top" command.

You can, however, trap one or more events that are likely to happen often (selection change, for example) and let that event trigger code that looks at each shape on the slide(s) and moves your watermark shape to front if it's not already there.



来源:https://stackoverflow.com/questions/24013871/in-powerpoint-2010-2013-how-to-keep-watermark-always-on-top-using-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!