ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 1523|回复: 1

PPT 修改 标题文本框字体 VBA 批处理

[复制链接]

TA的精华主题

TA的得分主题

发表于 2018-5-18 16:24 | 显示全部楼层 |阅读模式

  1. 'log:
  2. 'vba makes your daily work efficiently and effectively
  3. 'created date: 2018-05-18
  4. 'website for reference:
  5. 'http://club.excelhome.net/forum.php?mod=viewthread&tid=938911&extra=
  6. 'http://blog.sina.com.cn/s/blog_4928aeee0101bjvd.html
  7. 'codes help you to change the fonts in a batch mode with VBA

  8. 'ajust all fonts in PPT

  9. Sub font1()
  10.     Dim mySlide As Slide
  11.     Dim myShape As Shape
  12.     Dim myRng   As TextRange
  13.     With ActivePresentation
  14.         For Each mySlide In .Slides
  15.             For Each myShape In mySlide.Shapes
  16.                 If myShape.HasTextFrame Then
  17.                     Set myRng = myShape.TextFrame.TextRange
  18.                     myRng.font.Name = "Arial"  'change font
  19.                     'myRng.font.Color.RGB = RGB(0, 0, 255)
  20.                 End If
  21.             Next
  22.         Next
  23.     End With
  24. End Sub

  25. 'ajust the font in first textbox for all slides
  26. Sub font2()
  27. On Error Resume Next
  28. Dim oPres As Presentation
  29. Set oPres = Application.ActivePresentation
  30. Dim oSlide As Slide
  31. Dim oShape As Shape
  32. Dim tr As TextRange
  33. Dim sText As String
  34. Dim i As Long, j As Long
  35. Dim fjd As Integer

  36. For i = 1 To oPres.Slides.Count  'each slide
  37.     Set oSlide = oPres.Slides.Item(i)
  38.    
  39.     fjd = oSlide.Shapes.Count
  40.    
  41.     For j = 1 To 1   'first item as title
  42.         
  43.         Set oShape = oSlide.Shapes.Item(j)
  44.         
  45.         If oShape.TextFrame.HasText = msoTrue Then
  46.             Set tr = oShape.TextFrame.TextRange
  47.             tr.font.NameAscii = "Arial"         'change font
  48.             tr.font.NameFarEast = "Arial"
  49.             tr.font.Size = 50
  50.             'tr.font.Color.RGB = RGB(Red:=255, Green:=192, Blue:=0)
  51.                      
  52.             Set tr = Nothing
  53.         End If
  54.         Set oShape = Nothing
  55.     Next j
  56.    
  57. Next i
  58. Set oPres = Nothing
  59. End Sub
复制代码


TA的精华主题

TA的得分主题

 楼主| 发表于 2018-5-18 16:34 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
参考附件 测试文件

test of font change.zip

29.51 KB, 下载次数: 14

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-4-27 01:10 , Processed in 0.027908 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表