Consulting

Results 1 to 12 of 12

Thread: Change shapecolour when click on shape in presentation mode

  1. #1
    VBAX Regular
    Joined
    Aug 2010
    Posts
    15
    Location

    Change shapecolour when click on shape in presentation mode

    Hello everybody
    I'm new to this forum and also to vba programming. I would like a shape to change it's colour, when I cklick on the shape in presentation modus.

    I've found a solution in the internet:

    Sub changecol(oshp As Shape)
    On Error GoTo errhandler
    oshp.Fill.ForeColor.RGB = RGB(255, 0, 0)
    Exit Sub
    errhandler:
    MsgBox "Sorry there's an error"
    End Sub
    The problem: It just won't work. When I assign this macro to a shape, nothing happens and when I trie to run it form the vba IDE I can't find the macro listet there..?


    Is there anybody who could help?
    Thank's a lot

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Hi

    It shouldn't list in the available macros because it requires a variable (oshp) to be passed.

    If it doesn't run in show mode and you have set an action odf run macro on the shape to be clicked then the culprit is likely to be a buggy security update. KB 982158

    Try deleting the update in control panel
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Contributor
    Joined
    May 2008
    Posts
    198
    Location
    Also, if all you're trying to do is change the color of the shape, you can do this with a simple animation: "Emphasis:Change Fill Color". No VBA needed.

  4. #4
    VBAX Regular
    Joined
    Aug 2010
    Posts
    15
    Location
    Hello John Wilson and Cosmo
    sorry, I had no internet access the las few days - so, thank you very much for your replies!

    John, I thought your tip would bring the solution. In the meantime I found out, that the problem I described didn't pop up when I used an other computer. So it sounded very promising to remove this KB982158.

    But - this KB is not installed on my machine. I have VISTA 32 and Office 2010 Professional plus (German version) running on my machine and earlier before, I had Office 2007 installed.

    Could there be another buged KB?

    To Cosmo:
    I do need VBA, because I also want to safe the information, that a specific shape was clicked, to a variable.

    So many thanks to John and Cosmo and I would appreciate any other idea to resolve this problem.

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Here 2010 always works even with the update.

    There are some random thoughts here which might help
    http://www.pptalchemy.co.uk/PowerPoi...n_Refresh.html
    AND
    http://www.vbaexpress.com/forum/showthread.php?t=32622
    Last edited by John Wilson; 08-21-2010 at 05:58 AM.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  6. #6
    VBAX Regular
    Joined
    Aug 2010
    Posts
    15
    Location
    Thank you, John, for the interesting links, though they didn't bring the solution. Perhaps I will try to deinstall Office completely (including the updates) and reinstall it again...

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Try changing the code to this:
    [vba]Sub changecol(oshp As Shape)
    On Error GoTo errhandler
    MsgBox "OK"
    oshp.Fill.ForeColor.RGB = RGB(255, 0, 0)
    Exit Sub
    errhandler:
    MsgBox "Sorry there's an error"
    End Sub[/vba]
    This way if you don't get an OK message the code isn't running at all and you can look for the reason.

    If the OK appears hit esc and see if the color has changed in edit mode.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  8. #8
    VBAX Regular
    Joined
    Aug 2010
    Posts
    15
    Location
    Hello John
    I tried and copied your script to the IDE of an empty presentation by copy-paste - and it worked (no errors).

    Then, I copied your script by writing exactely the same script again (into the same module), assigning it a new name - and it didn't run at all (the MsgBox "OK" didn't show up ). So I guess, there must be something wrong with the IDE - what do you think?

  9. #9
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    What is the name of the powerpoint file? There's a bug if the name contains ! the code will not run in show mode.

    You do realise that this code will only run when a shape is clicked in show mode?
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  10. #10
    VBAX Regular
    Joined
    Aug 2010
    Posts
    15
    Location
    The file name is Präsentation1.pptm.

    Yes, I got that - the script runs only in show mode (that's what I want)... I tried it in show mode.

  11. #11
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    If you want to mail me a sample I'll see if I can see whats wrong
    john ATSIGN pptalchemy.co.uk
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  12. #12
    VBAX Regular
    Joined
    Aug 2010
    Posts
    15
    Location
    Hello John
    I tried to run the script on an other computer - and it worked... but even better: when I copied the presentation back to the original "problem-computer" it als worked!

    So I guess, we can close this topic. Thank you very much for the support!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •