简体   繁体   English

Powerpoint的VBA宏可更改注释颜色

[英]VBA Macro for Powerpoint to change Notes color

I've just started learning programming in VBA for PowerPoint (about 30 mins ago). 我刚刚开始在VBA for PowerPoint中学习编程(大约30分钟前)。 Could anyone help me with the following?: 谁能在以下方面为我提供帮助?:

I want a Macro that loops through all the slides' notes and changes the text to white 我想要一个宏,可以循环浏览所有幻灯片的注释并将文本更改为白色

(I know there are non-macro alternatives to this but third-party software (Articulate) requires it be done via a Macro... long story). (我知道有一些非宏的替代方法,但是第三方软件(Articulate)要求通过Macro ...来完成)。

This is what I have so far: 这是我到目前为止的内容:

Sub changenotestowhite()
   Dim osld As Slide
   Dim oshp As Shape
   Dim strNotes As String
   For Each osld In ActivePresentation.Slides
      For Each oshp In osld.NotesPage.Shapes
         oshp.TextFrame.TextRange.Font.Color = vbWhite
      Next oshp
   Next osld
End Sub

I get the error message "Run-time error: the specified value is out of range." 我收到错误消息“运行时错误:指定的值超出范围”。

Thanks! 谢谢!

Joe

Welcome to the world of MS/VB's Famous Red Herrings (aka error messages). 欢迎来到MS / VB的著名红鲱鱼世界(又名错误消息)。

The problem is this: some shapes don't have a text frame (the property of a shape that holds text) and even if a shape has a text frame, there may not be any text in it. 问题是这样的:某些形状没有文本框架(保存文本的形状的属性),即使形状具有文本框架,其中也可能没有任何文本。 Attempting to change text that isn't there, or text in a text frame that isn't there will throw an error. 尝试更改不存在的文本或文本框架中不存在的文本将引发错误。

Use this instead, which tests for text frame and if present, whether the text frame has text prior to changing the text in any way: 请改用此命令,以测试文本框架以及是否存在文本框架(如果存在),然后以任何方式更改文本:

Sub changenotestowhite()
   Dim osld As Slide
   Dim oshp As Shape
   Dim strNotes As String
   For Each osld In ActivePresentation.Slides
      For Each oshp In osld.NotesPage.Shapes
        If oshp.HasTextFrame Then
        If oshp.TextFrame.HasText Then
         oshp.TextFrame.TextRange.Font.Color = vbWhite
         End If
         End If
      Next oshp
   Next osld
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM