最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to update font color data in vba powerpoint in the slideshow mode? - Stack Overflow

programmeradmin3浏览0评论

I have a PowerPoint presentation with various shapes containing text, where the text is black except for one shape, which has red font color. The font color of different shapes changes to red through various font color change effects controlled by different triggers. Additionally, in the presentation, I have an action button linked to a macro that is supposed to return the names of the shapes that currently have red font color. The macro works fine when I run it right after starting the slide show, but the problem is that if I start clicking on triggers and changing the font color of different shapes, when I click the action button again, it does not show the new shapes whose font color has changed to red. Does anyone know why?

Private Sub CommandButton1_Click()

Dim oSld As Slide
Dim oSh As Shape

Set oSld = ActivePresentation.SlideShowWindow.View.Slide

For Each oSh In oSld.Shapes

If oSh.TextFrame.HasText = msoTrue Then
If oSh.TextFrame.TextRange.Font.Color.RGB = RGB(255, 0, 0) Then

MsgBox oSh.Name

End If
End If

Next oSh

End Sub

I have a PowerPoint presentation with various shapes containing text, where the text is black except for one shape, which has red font color. The font color of different shapes changes to red through various font color change effects controlled by different triggers. Additionally, in the presentation, I have an action button linked to a macro that is supposed to return the names of the shapes that currently have red font color. The macro works fine when I run it right after starting the slide show, but the problem is that if I start clicking on triggers and changing the font color of different shapes, when I click the action button again, it does not show the new shapes whose font color has changed to red. Does anyone know why?

Private Sub CommandButton1_Click()

Dim oSld As Slide
Dim oSh As Shape

Set oSld = ActivePresentation.SlideShowWindow.View.Slide

For Each oSh In oSld.Shapes

If oSh.TextFrame.HasText = msoTrue Then
If oSh.TextFrame.TextRange.Font.Color.RGB = RGB(255, 0, 0) Then

MsgBox oSh.Name

End If
End If

Next oSh

End Sub
Share Improve this question asked Mar 20 at 9:03 Francisco VeraFrancisco Vera 32 bronze badges 3
  • PowerPoint references shape properties as they are stored in the file, not as they are modified by an animation. – John Korchok Commented Mar 20 at 16:04
  • then there is no way to get the modificacation of the shapes that is consecuence of the animations on real time? – Francisco Vera Commented Mar 21 at 10:30
  • @FranciscoVera You could a tag on the shape that reflects the current color. Ex oShape.Tags.Add "CurrentColor", "RED" and to retrieve the value, MsgBox oShape.Tags("CurrentColor) – Steve Rindsberg Commented Mar 21 at 14:14
Add a comment  | 

1 Answer 1

Reset to default 0

In your code be sure to use a gotoslide before rechecking. So add in

ActivePresentation.View.slideshowWindow.View.GoToSlide(osld.SlideNumber)

When you do this before the code it reloads that osld so it can check the changes. Try this out

Edit. I see you are changing the font by use of an animation. This is much more tricky. You would need that animation to trigger a macro that adds a shape tag and then check for that tag in your loop. Then the gotoslide like I mentioned.

发布评论

评论列表(0)

  1. 暂无评论