20170709pptVBA递归删除LOGO图片与文字

Public Sub StartRecursionFolder()
    Dim Pre As Presentation
    Dim FolderPath As String
    Dim pp As String
    Dim id As String

    Dim oFileDialog As FileDialog
    Set oFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
    ‘Set Pre = Application.ActivePresentation
    With oFileDialog
        .AllowMultiSelect = False
        ‘.InitialFileName = Pre.Path & "\"
        If .Show = 0 Then Exit Sub
    End With
    FolderPath = oFileDialog.SelectedItems(1) & "\"
    ‘递归处理
    RecursionFolder FolderPath
    ‘MsgBox "批处理完成"
End Sub
Public Sub PresentationHandle(ByVal FilePath As String)
    Application.DisplayAlerts = ppAlertsNone
    Dim Pre As Presentation
    Dim mst As Master
    Dim sld As Slide
    Dim shp As Shape
    Debug.Print FilePath
    Set Pre = Application.Presentations.Open(FilePath)
    ‘******************************母版的处理**********************
    Dim dsg As Design
    Debug.Print "模板个数"; Pre.Designs.Count

    For Each dsg In Pre.Designs

        Set mst = dsg.SlideMaster
        For Each shp In mst.Shapes
            ‘删除条件
            Debug.Print shp.Width & "/" & shp.Height; "   "; BetweenSize(shp.Width, 145, 160) And BetweenSize(shp.Height, 30, 55)
            If BetweenSize(shp.Width, 145, 160) And BetweenSize(shp.Height, 30, 55) Then
                shp.Delete
            End If
        Next shp

        If dsg.HasTitleMaster Then
            Set mst = dsg.TitleMaster
            For Each shp In mst.Shapes
                ‘删除条件
                Debug.Print shp.Width & "/" & shp.Height; "   "; BetweenSize(shp.Width, 145, 160) And BetweenSize(shp.Height, 30, 55)
                If BetweenSize(shp.Width, 145, 160) And BetweenSize(shp.Height, 30, 55) Then
                    shp.Delete
                End If
            Next shp
        End If

    Next dsg

    For Each sld In Pre.Slides
        For Each shp In sld.Shapes
            ‘删除条件
            If BetweenSize(shp.Width, 145, 160) And BetweenSize(shp.Height, 30, 55) Then
                shp.Delete
            End If
        Next shp
    Next sld

    DeleteShapsInPresentation Pre

    Pre.Save

    Pre.Close

    Set Pre = Nothing
    Set mst = Nothing
    Set sld = Nothing

    Application.DisplayAlerts = ppAlertsAll
End Sub
Private Function BetweenSize(ByVal Size As Double, ByVal MinSize As Double, ByVal MaxSize As Double) As Boolean
    If Size >= MinSize And Size <= MaxSize Then
        BetweenSize = True
    Else
        BetweenSize = False
    End If
End Function
Public Sub RecursionFolder(ByVal FolderPath As String)    ‘递归文件夹
‘声明对象
    Dim Fso As Object
    Dim MainFolder As Object
    Dim OneFolder As Object
    Dim OneFile As Object
    ‘实例化对象
    Set Fso = CreateObject("Scripting.FileSystemObject")
    Set MainFolder = Fso.GetFolder(FolderPath)
    ‘对文件执行操作
    For Each OneFile In MainFolder.Files
        If OneFile.Name Like "*.ppt*" Then
            ‘具体要做的事情
            PresentationHandle OneFile.Path
        End If
    Next
    ‘递归
    For Each OneFolder In MainFolder.SubFolders
        RecursionFolder OneFolder.Path
    Next
    ‘释放对象
    Set Fso = Nothing
    Set MainFolder = Nothing
End Sub

Private Sub DeleteShapsInPresentation(ByVal Pre As Object)
    Dim sld As Slide
    Dim shp As Shape
    Dim Txt As String
    For Each sld In Pre.Slides
        For Each shp In sld.Shapes
            If shp.HasTextFrame = msoTrue Then
                If shp.TextFrame.HasText Then
                    Txt = shp.TextFrame.TextRange.Text
                    If Txt Like "*更多免费资料下载请进*" Then
                        shp.Delete
                    End If
                End If
            End If
        Next
    Next
    For Each shp In Pre.SlideMaster.Shapes
        If shp.HasTextFrame = msoTrue Then
            If shp.TextFrame.HasText Then
                Txt = shp.TextFrame.TextRange.Text
                If Txt Like "*更多免费资料下载请进*" Then
                    shp.Delete
                End If
            End If
        End If
    Next

End Sub

  

时间: 2024-10-12 13:58:50

20170709pptVBA递归删除LOGO图片与文字的相关文章

ASP.NET(C#)图片加文字、图片水印,神啊,看看吧

ASP.NET(C#)图片加文字.图片水印 一.图片上加文字: //using System.Drawing; //using System.IO; //using System.Drawing.Imaging; private void AddTextToImg(string fileName,string text) { if(!File.Exists(MapPath(fileName))) { throw new FileNotFoundException("The file don't

CSS控制图片和文字在同一行显示且对齐的3种方法

CSS控制图片和文字在同一行显示且对齐的3种方法 在 HTML 代码中,有时会需要在文字旁边加上一个图标. 默认情况,是图片置顶对齐,文字置底对齐,所以通常图片高,文字低,不能水平居中对齐. 常见方法有3种:1.通过添加css的“vertical-align:middle;”:2.如果图片是背景图片,可以在css中设置背景图片:3.把文字和图片分别放入不同的div中.上面三种方法都可以让图片和文字在同一行显示,下面我们用实例来应用一下. 1.添加上“vertical-align:middle”属

演讲稿图片转文字怎样操作?

对于一位演讲者来说,稿子是演讲的一个利器,可以帮助演讲者更有底气的去演讲.如果在演讲中我们的演讲稿有了大部分的改动,还要转换成文字,那么我们是不是在原有的备份里,一点一点的删除,增加内容呢?小编今天就分享给大家一种演讲稿图片直接转换文字的操作技巧. 第一步:首先,我们需要有一款OCR文字识别软件工具,这样我们就可以借助这样的工具进行图片转文字的操作了.没有OCR文字识别工具的小伙伴们就是需要在浏览器搜索,下载安装类似的工具啦.详细的安装步骤就不一一在这里讲解啦,和我们平时安装的其他软件都是差不多

java递归删除文件及目录

package base; import java.io.File; public class delete { public static void main(String[] args) { deleteFileAndFoder("../yang"); } static void deleteFileAndFoder(String path){ File f=new File(path); if(f.isDirectory()){//假设是文件夹.先递归删除 String[] li

css控制图片与文字对齐

文字旁边搭配图片时,发现图片比文字靠上,原来默认的情况是图片顶对齐而文字底对齐,通过设置css属性可以使得图片与文字对齐. 设置各对象的vertical-align属性,属性说明:baseline-将支持valign特性的对象的内容与基线对齐sub-垂直对齐文本的下标super-垂直对齐文本的上标top-将支持valign特性的对象的内容与对象顶端对齐text-top-将支持valign特性的对象的文本与对象顶端对齐middle-将支持valign特性的对象的内容与对象中部对齐bottom-将支

XenApp/XenDesktop 7.11中对于视频、图片、文字的优化的说明

在桌面虚拟化这个技术门类中,市面上一共主流有以下几种协议: Citrix的ICA/HDX协议 Teradici公司的PCoIP(VMware Horzion中主要使用的协议之一) 微软公司的RDP RedHat公司的spice 以及近两年我们能接触到的 VMware公司的Blast(VMware在Horizion 6版本以后开始提供的协议,有逐步替代PCoIP的趋势) 华为的HDP 但是无论怎么墙头变换大王旗,Citrix的ICA/HDX协议可以说多年来一直都是行业最为优秀的企业级远程交付协议.

JUnit 3.8 演示递归删除文件目录的 测试类程序 .

用递归方式来实现删除硬盘的文件或目录(空文件夹) 首先要找到递归的入口及出口,这点很重要,成败在此,呵呵! 代码实现: [java] view plain copy import java.io.File ; class RecursionDeleteFileDemo //利用递归 删除 文件或目录 操作 { public static void deleteFiles(File file) { //递归出口 //判断目前文件,如果是文件 或 是一个空的文件夹,则删除 if(file.isFil

鼠标滑过图片变暗文字链接滑出jQuery特效

效果体验:http://hovertree.com/texiao/jquery/7.htm HTML文件代码: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>鼠标滑过图片变暗文字链接滑出jQuery特效 - HoverTree</title><base target="_blank" /> &l

window 7 64位下可运行的递归删除注册表程序

为了完成一个简单的注册表删除程序,由于我本身是win7 64位的OS,写了以下代码来递归删除注册表键值,程序代码如下: #include <tchar.h> #include <afx.h> #define KEY_WOW64_64KEY 256 long DeleteSubKeyTree(HKEY hKey, LPCTSTR lpSubKey) { LONG lResult; HKEY hSubKey; DWORD dwIndex, cbName; char szSubKey[5