本文介绍了在PowerPoint 2010/2013中,如何使用VBA将水印始终放在首位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个小的VBA程序在后台应用一些文本.我可以应用水印,但是如果我在演示文稿中使用任何图像,那么水印就会落后于该图像.有什么办法可以使水印始终保持在最前面.我正在使用此代码来应用水印:

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

推荐答案

不,您放在任何东西上面的东西都会掩盖它.没有在顶部保留此形状"命令.

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.

这篇关于在PowerPoint 2010/2013中,如何使用VBA将水印始终放在首位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 22:20