单击时更改图像边框颜色的 vba 电源点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15624199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 20:14:41  来源:igfitidea点击:

vba power point changing image border color on click

imagevbacolorsborderpowerpoint

提问by user2209106

I'm trying to make an educational interactive presentation for kinder children using Power Point, and I'm trying to do a kind of test/activity in which the children have to click on some pictures according to the question. Some will be right, some don't. (for instance: can you point the tools used by a fireman? and show 4 images of different tools) Using the mousemove event, I can reproduce a sound that says the name of the object, and using the click event I can reproduce another sound to tell the children "wrong" or "right". Now, I would like to change the border of the picture they are clicking on (color and or width), but I have no clue how to do it in VBA. It must be very easy, but I don't know the sintax :-( Any help? Please? Thank you!

我正在尝试使用 Power Point 为幼儿园的孩子们制作一个教育互动演示,我正在尝试做一种测试/活动,孩子们必须根据问题点击一些图片。有些会是对的,有些则不会。(例如:你能指出消防员使用的工具吗?并显示 4 张不同工具的图像)使用 mousemove 事件,我可以重现一个说对象名称的声音,使用 click 事件我可以重现另一个声音告诉孩子们“错”或“对”。现在,我想更改他们单击的图片的边框(颜色和/或宽度),但我不知道如何在 VBA 中执行此操作。这一定很容易,但我不知道语法 :-( 有什么帮助吗?拜托?谢谢!

回答by Kazimierz Jawor

You would be surprised but it's not so easy as you expected, of course, when doing smartly with classes and events.

您会感到惊讶,但当然,当巧妙地处理类和事件时,这并不像您预期​​的那么容易。

I'll give you simple idea, so if you have time and really need it you could go this way. But there would be some problems- you will have to figure out how could you get starting borders of your shapes.

我会给你一个简单的想法,所以如果你有时间并且真的需要它,你可以走这条路。但是会有一些问题 - 您必须弄清楚如何获得形状的起始边界。

Here is idea how to start.

这是如何开始的想法。

  1. name each of the shape on the slide- select one and run the following instruction in Immediate window in VBA editor, eg.:

    ActiveWindow.Selection.ShapeRange.Name = "Fireman"
    
  2. to change the color and line write macro for each shape (this will run only in slideshow view):

    Sub FiremanClick()
    
    With SlideShowWindows(1).View.Slide.Shapes("Fireman").Line
        .Weight = 2
        .ForeColor.RGB = RGB(255, 0, 0)
    End With
    
    
    End Sub
    
  3. in application right-click fireman shape and associate action with macro you wrote.

  4. you will need to figure out how to set back standard setting of each shape and when.

  1. 为幻灯片上的每个形状命名 - 选择一个并在 VBA 编辑器的立即窗口中运行以下指令,例如:

    ActiveWindow.Selection.ShapeRange.Name = "Fireman"
    
  2. 更改每个形状的颜色和线条写入宏(这将仅在幻灯片视图中运行):

    Sub FiremanClick()
    
    With SlideShowWindows(1).View.Slide.Shapes("Fireman").Line
        .Weight = 2
        .ForeColor.RGB = RGB(255, 0, 0)
    End With
    
    
    End Sub
    
  3. 在应用程序中右键单击消防员形状并将操作与您编写的宏相关联。

  4. 您将需要弄清楚如何设置每个形状的标准设置以及何时设置。

回答by George

For some reason, some kind of bug happens when setting the border shape color first and then the weight, the shape border color becomes the generic blue one in PowerPoint 2010.

由于某种原因,在先设置边框形状颜色然后设置粗细时,会发生某种错误,形状边框颜色在 PowerPoint 2010 中变成了通用的蓝色。