Powerpoint VBA help!!

ChrisAtraen
NewLounger
Posts: 5
Joined: 12 Mar 2015, 08:43

Powerpoint VBA help!!

Post by ChrisAtraen »

Hi there, Not sure whether this would be better off placed in the VBA section or not, but it is a powerpoint problem, so here goes! I'm currently working on making a game for one of my schools and I can't quite get the VBA working. I took the code out of another powerpoint, which although works fine in the other powerpoint, is not functioning in this one.

Here is a screen shot of the scoreboard:

Image

When I click the upwards arrow beside 'OdaAtt' (the selected box) I want it the score increase by 1 point. Likewise when I hit the down arrow I want the score to decrease by one.

The code I am using is as follows:

Option Explicit
Dim scoreOdaAtt As Long

Sub Add1OdaAtt()
scoreOdaAtt = scoreOdaAtt + 1
UpdateScores
End Sub
Sub Minus1OdaAtt()
scoreOdaAtt = scoreOdaAtt - 1
UpdateScores
End Sub

Sub UpdateScores()
ActivePresentation.Slides("Slide7").Shapes("OdaAtt").TextFrame.TextRange.Te xt = scoreOdaAtt
End Sub

I would really appreciate any help anyone can offer!!
Thanks in advance!

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Powerpoint VBA help!!

Post by StuartR »

How is the code attached to the arrows? Is the code actually executing when you click the up or down arrow button?
StuartR


ChrisAtraen
NewLounger
Posts: 5
Joined: 12 Mar 2015, 08:43

Re: Powerpoint VBA help!!

Post by ChrisAtraen »

I attached an action to the box which the arrows are in which should fire off the macro, but doesn't. It acts like a link would allowing me to click it but the score doesn't change. The box is called OdaAtt according to the selection sidebar.
Last edited by ChrisAtraen on 12 Mar 2015, 10:57, edited 1 time in total.

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Powerpoint VBA help!!

Post by StuartR »

Are you clicking the arrow while you are in edit mode, or while the slide show is running?
Can you cut your presentation down to just one arrow, zip it and upload it to this thread
StuartR


ChrisAtraen
NewLounger
Posts: 5
Joined: 12 Mar 2015, 08:43

Re: Powerpoint VBA help!!

Post by ChrisAtraen »

Whilst the slide show is running, sure I'll upload it! Thanks!

ChrisAtraen
NewLounger
Posts: 5
Joined: 12 Mar 2015, 08:43

Re: Powerpoint VBA help!!

Post by ChrisAtraen »

Here it is with just the box and up and down arrows, thanks.
You do not have the required permissions to view the files attached to this post.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Powerpoint VBA help!!

Post by Rudi »

Welcome to Eileen's lounge :)

It seems to be the slide number that is the issue.
I changed it to refer to Slide4 and it is functioning fine now in the attached...

Extra detail quoted from Stack Overflowl...
There is no built-in functionality in PowerPoint that allows you to edit the name of a slide. As Steve mentioned, you have to do it using VBA code. The slide name will never change due to inserting more slides, and it will stay the same even if you close PowerPoint; the slide name set in VBA code is persistent.
Here's some code to allow you to easily view the name of the currently selected slide and allow you to rename it.
Sengoku_EDIT.pptm
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

ChrisAtraen
NewLounger
Posts: 5
Joined: 12 Mar 2015, 08:43

Re: Powerpoint VBA help!!

Post by ChrisAtraen »

Ah, you're a hero! haha! Yeah I went back to the original file, changed everything to refer to slide4 and it's running perfectly! I had no idea the slide name doesn't change unless you change it using vba, very interesting! Anyway, that seems to have fixed everything, so consider this case closed :) Thanks again!!

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Powerpoint VBA help!!

Post by Rudi »

To be honest, I learned this for the first time too...
TX for your question; we are both the wiser now. :thumbup:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.