PDA

View Full Version : Change shapecolour when click on shape in presentation mode



pptSam
08-16-2010, 02:30 AM
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:banghead:. 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

John Wilson
08-17-2010, 07:44 AM
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

Cosmo
08-17-2010, 11:52 AM
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.

pptSam
08-21-2010, 05:15 AM
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 :friends: and I would appreciate any other idea to resolve this problem.

John Wilson
08-21-2010, 05:46 AM
Here 2010 always works even with the update.

There are some random thoughts here which might help
http://www.pptalchemy.co.uk/PowerPoint_Screen_Refresh.html
AND
http://www.vbaexpress.com/forum/showthread.php?t=32622

pptSam
08-22-2010, 02:53 AM
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... :think:

John Wilson
08-22-2010, 12:00 PM
Try changing the code to this:
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
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.

pptSam
08-24-2010, 07:46 AM
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 :bug:). So I guess, there must be something wrong with the IDE - what do you think?

John Wilson
08-24-2010, 08:22 AM
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?

pptSam
08-24-2010, 01:29 PM
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.

John Wilson
08-25-2010, 09:17 AM
If you want to mail me a sample I'll see if I can see whats wrong
john ATSIGN pptalchemy.co.uk

pptSam
08-27-2010, 05:08 AM
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!:friends: