Const ModelText As String = "机构名称"
Const ModelName As String = "测试文件.pptx" Sub NextSeven_CodeFrame()
'应用程序设置
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
'错误处理
On Error GoTo ErrHandler
'计时器
Dim StartTime, UsedTime As Variant
StartTime = VBA.Timer '变量声明
Dim Wb As Workbook
Dim Sht As Worksheet
Dim Rng As Range
Dim Arr As Variant
Dim EndRow As Long Dim pApp As Object
Dim Pre As Object
'Dim pApp As PowerPoint.Application
'Dim pre As PowerPoint.Presentation Dim FindStr As String
Dim ReplaceStr As String
Dim FilePath As String
Dim FolderPath As String
Dim tmp As String Dim FileName As String
FileName = Left(ModelName, InStrRev(ModelName, ".") - 1)
'实例化对象
Set Wb = Application.ThisWorkbook
Set Sht = Wb.Worksheets(1)
FolderPath = Wb.Path & "\"
'Set pApp = New PowerPoint.Application
Set pApp = CreateObject("PowerPoint.Application")
Debug.Print FolderPath & ModelName
Set Pre = pApp.Presentations.Open(FolderPath & ModelName)
With Sht
EndRow = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row
Set Rng = .Range("A1:Z" & EndRow)
Arr = Rng.Value
For i = LBound(Arr) To UBound(Arr)
If i = 1 Then
FindStr = ModelText
ReplaceStr = Arr(i, 1)
FilePath = FolderPath & FileName & "_予" & Arr(i, 1) & ".pdf"
ReplaceAndPublish Pre, FilePath, FindStr, ReplaceStr
Else
FindStr = Arr(i - 1, 1)
ReplaceStr = Arr(i, 1)
FilePath = FolderPath & FileName & "_予" & Arr(i, 1) & ".pdf"
ReplaceAndPublish Pre, FilePath, FindStr, ReplaceStr
End If
Next i
End With
'运行耗时
UsedTime = VBA.Timer - StartTime
'MsgBox "本次运行耗时:" & Format(UsedTime, "0.0000000秒")
ErrorExit: '错误处理结束,开始环境清理
Pre.Close
Set Pre = Nothing
pApp.Quit
Set pApp = Nothing
Set Wb = Nothing
Set Sht = Nothing
Set Rng = Nothing Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
Exit Sub
ErrHandler:
If Err.Number <> 0 Then
MsgBox Err.Description & "!", vbCritical, "错误提示!"
'Debug.Print Err.Description
Err.Clear
Resume ErrorExit
End If
End Sub
Private Sub ReplaceAndPublish(ByVal Pre As Object, ByVal FilePath As String, ByVal FindText As String, ByVal ReplaceText As String)
Dim sld As PowerPoint.Slide
Dim shp As PowerPoint.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 InStr(1, Txt, FindText) > 0 Then
shp.TextFrame.TextRange.Text = Replace(Txt, FindText, ReplaceText)
Exit For
End If
End If
End If
Next
Next
Pre.SaveAs FilePath, ppSaveAsPDF
End Sub

  

20161226xlVBA演示文稿替换文字另存pdf的更多相关文章

  1. pdf 移除密码 去除水印 批量去除水印 编辑文字 批量替换文字

    1.pdf除密码: http://pan.baidu.com/share/link?shareid=308194398&uk=370045712  2.去除水印:http://wenku.ba ...

  2. 怎样做出优秀的扁平化设计风格 PPT 或 Keynote 幻灯片演示文稿?(装)

    不知道你有没有想过,为什么很人多的扁平化 PPT 是这个样子: 或者是这样: 然而,还有一小撮人的扁平化 PPT 却拥有那么高颜值: 为什么会产生这么大的差距呢?丑逼 PPT 应该如何逆袭成为帅逼呢? ...

  3. 放映PPT幻灯片演示文稿如何让演讲者备注不投影到屏幕上(转载)

    ps  files/ps.rar 放映PPT幻灯片演示文稿如何让演讲者备注不投影到屏幕上 如题,在PPT幻灯片的演示文稿中加入演讲者备注(使用PPT讲座时苦于有时会忘记一些要讲的数字,文字等),但是在 ...

  4. Hyhyhy – 专业的 HTML5 演示文稿工具

    Hyhyhy 是创建好看的 HTML5 演示文档的工具.它具备很多的特点:支持 Markdown,嵌套幻灯片,数学排版,兼容性,语法高亮,使用 Javascript API ,方便的骨架.它支持 Fi ...

  5. slid.es – 创建在线幻灯片和演示文稿的最佳途径

    slid.es 提供了一种创建在线幻灯片和演示文稿的简单方法,让你通过几个简单的步骤制作效果精美的在线演示文稿.基于 HTML5 和 CSS3 实现,在现代浏览器中效果最佳. 您可能感兴趣的相关文章 ...

  6. VBA表格单元格替换文字

    Sub 表格单元格替换文字() If MsgBox("确定要替换单元格的文字吗?", vbYesNo + vbQuestion) = vbYes Then To ActiveDoc ...

  7. Reveal.js一个用来做WEB演示文稿的框架

    reveal.js是一个能够帮助我们很轻易地使用HTML来创建漂亮的演示效果,也就是我们常见的PPT幻灯片.reveal.js不依赖其他任何javascript库,是一个独立的javascript插件 ...

  8. 解决方案:ppt打不开,显示发现文件中的内容有问题。可尝试修复此演示文稿

    ppt打不开,显示发现文件中的内容有问题.可尝试修复此演示文稿 故障截图如下: 解决方法: 主要是因为文件是网络下载的,office自动锁定了文件(默认不可编辑).在文件上右键-属性-解除锁定(最下面 ...

  9. Liferay平台开发使用详细PPT演示文稿

    主要章节: 概述 功能和使用 开发扩展 安全.认证 高可用 Demo 独立流程演示工程: Liferay集成Activiti开发工程: PPT演示文稿下载 Demo程序分2部分: 独立流程演示工程:h ...

随机推荐

  1. cf463d

    这题说的是给了k个串算出这k个串的最长公共子序列,这k个串每个串都是由1--n的数字组成的. 将第一串的数字按照顺序重新编号为123...n 然后后面的串按照这个编号重新标号,就转化为下面每个串大最长 ...

  2. Pointofix 1.7 Portable试用

    Pointofix 1.7 Portable简体中文单文件便携版 软件大小:347K软件语言:简体中文软件类别:国外软件/桌面工具/教育教学运行环境:windows XP/Vista/Win7开 发 ...

  3. MAC安装最新datagrip之后无法非官方激活,而且启动过慢

    由于之前安装过,更新最新版本之后发现不能使用(http://xidea.online)激活??? 解决方法:使用CleanMyMac等相应软件删除之后,还要去相应的保存记录的路径(/Users/用户名 ...

  4. HTML JavaScript 基础学习

    HTML 中肯定会用到 JavaScript 的知识点,会点 JavaScript 的基础知识不会吃亏,其实打算去买JavaScript的教程去专门学习一下,但是交给我的时间不多了,记录一点,能会一点 ...

  5. npm 查看全局安装过的包

    查看全局安装的包 npm list -g --depth 0 非全局安装的包 npm list --depth 0 如果不加参数 --depth 0会显示安装的包以及相关的依赖包,会显示的很详细.

  6. noip2008 真题练习 2017.2.25

    不是有很多可以说的,记住不能边算边取min Code #include<iostream> #include<fstream> #include<sstream> ...

  7. hdu 3336 Count the string -KMP&dp

    It is well known that AekdyCoin is good at string problems as well as number theory problems. When g ...

  8. Python3基础 函数 未指定返回值,返回NONE

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  9. 在ubuntu下随意编译安装需要的python版本

    一.环境 ubuntu14.04 二.准备 2.1更新软件库 sudo apt-get update 2.2安装编译器及相应工具 2.3安装相应的开发库 sudo apt-get install zl ...

  10. spring boot application.properties/application.yml 配置属性大全

    来自官网  https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.h ...