PDA

View Full Version : Problem in adding picture to label in Powerpoint 2010



ntd252
05-01-2015, 06:00 AM
Hello everyone!
I am design a game in powerpoint 2010 for my class.
Now, I have a label. It's used to display the score. And I put it front of a picture. But the color of label isn't beautiful, it just has some basic color, while I want the color of it to be same with the picture in the back. So I see in the tab Cateforized of Properties (for label), I find a line "Picture (None)'' . I click and open the picture I want and the Label gets this picture as background
However, the score in the label can't be seen.

So is it possible to have the picture and also the score in a label? And how?
Thanks !

Paul_Hossler
05-01-2015, 06:48 AM
I usually put a no-fill textbox on the image

ntd252
05-01-2015, 07:21 AM
Oh it's great! How can you do? I cant edit shape for TextBox

ntd252
05-01-2015, 08:53 AM
Um now I realize your textbox is not what i am using. You use textbox from Insert, my textbox is an activex control so I can change the score during playing.

John Wilson
05-01-2015, 10:37 AM
Use a normal textbox. You can still change the score.

Paul_Hossler
05-01-2015, 01:13 PM
Attached is a simple example

It calls this macro when the picture is clicked in SlideShow mode




Option Explicit
Sub IncreaseScore()
Dim i As Long

If IsNumeric(Me.Shapes("TextBox 7").TextFrame.TextRange.Text) Then
i = CLng(Me.Shapes("TextBox 7").TextFrame.TextRange.Text)
Else
i = 0
End If

Me.Shapes("TextBox 7").TextFrame.TextRange.Text = Format(i + 1, "#,##0")
End Sub

ntd252
05-01-2015, 05:36 PM
It works as I want. Thanks a lot!
Can I get text (players' name) like the score on another textbox?

Paul_Hossler
05-01-2015, 06:05 PM
Can I get text (players' name) like the score on another textbox?

Probably, but where do you get it from?

You can add any text boxes you want

ntd252
05-02-2015, 06:26 PM
I guess it's from a variable.
I use your code on my slide but it doesn't work?
It is necessary to have "If... then...else " if my textbox is a number?

ntd252
05-03-2015, 03:36 AM
All right! Everything's done. I think the code can be more simple for my game, like this

Option Explicit

Sub IncreaseScore()
Dim i As Long
i = CLng(Slide1.Shapes("TextBox 7").TextFrame.TextRange.Text)
Slide1.Shapes("TextBox 7").TextFrame.TextRange.Text = Format(i + 1, "#,##0")


End Sub


Sub abc()
Dim a As String
a = Slide1.Shapes("TextBox 9").TextFrame.TextRange.Text
Slide1.Shapes("TextBox 5").TextFrame.TextRange.Text = a
End Sub



But there's still a problem. a can't get text from other slide, such as Slide2, I use a = Slide2.Shapes("TextBox 3").TextFrame.TextRange.Text on Slide1 (code) window, the error is "variable not defined". So how can I get textbox from other slides?

John Wilson
05-10-2015, 05:02 AM
A DONT change the if then part of Paul's code. It will crash if the textbox is not numeric if you do.
B I don't know why Paul did it that way but I wouldn't especially if you don't understand slide objects see my attachment
C Do you understand slide objects (I don't think so) Slide2 is NOT NECESSARILY the second slide.

If you are looking at a normal textbox
ActivePresentation.Slides(1).Shapes("TextBox 9").TextFrame.TextRange.Text=ActivePresentation.Slides(2).Shapes("TextBox 5").TextFrame.TextRange

If the textbox on slide 2 is an ActivX textbox
ActivePresentation.Slides(1).Shapes("TextBox 9").TextFrame.TextRange.Text=ActivePresentation.Slides(2).Shapes("TextBox 5").OLEFormat.Object.Text

Paul_Hossler
05-10-2015, 07:49 AM
@John --


I don't know why Paul did it that way but I wouldn't especially if you don't understand slide objects see my attachment

Paul didn't :devil2:

OP 'extended' Paul's code in #6 to come up with #10

I rarely use a object's code name (e.g. Slide1) unless I'm absolutely sure that I ALWAYS want to use that instance

John Wilson
05-10-2015, 07:56 AM
Wasn't getting at you Paul - I meant having the code in a Slide Object instead of a normal module which is not needed and can be confusing (if you don't understand it which I'm pretty sure the OP doesn't!)

And ntd Watch out for the extra spaces that the website has inserted in my code

Paul_Hossler
05-11-2015, 01:53 PM
OK, I was misinterpreting your point

But your paul.pptm doesn't seem to work, and I couldn't figure out a way to pass a Shape Object to your standard module macro

Never mind -- I got it -- nothing was happening since there was no Text Box7 on the slide -- added it and now it works, but ONLY if the objects are named the same.


However, I did it this way ...




Option Explicit
Sub IncreaseScore()
Dim i As Long

If IsNumeric(Me.Shapes("TextBox 7").TextFrame.TextRange.Text) Then
i = CLng(Me.Shapes("TextBox 7").TextFrame.TextRange.Text)
Else
i = 0
End If

Me.Shapes("TextBox 7").TextFrame.TextRange.Text = Format(i + 1, "#,##0")
End Sub


since the objects and actions are on the slide that receives the action and that if the slide is copied for another question, the action would then go to the new slide

I would have renamed the objects using the Selection Pane you taught me so long ago to make it easier for maintenance, but I followed the OP's path and stayed with the default names

Another question -- does the Shape get passed to the call like that every time? I don't think I ever knew that

ntd252
06-16-2015, 06:23 PM
Hey friends!
this post for me to announce that my game has been completed 70%, yeah, it should be done soon, but I try it for my class and everything went done, though something not convenient. I am trying to complete it for a perfect version that our class can use in the final round, and of course, I will show you my game, on Youtube, and on the file.
Something is not convenient because they're difficult to replace for new round each week. My game is about knowledge. at the first round, I have 12 questions for each student (there is 4 students at all). a student have to answer them, after each his(her) answer, I click a shape to play the next animation - the next questions. I put 12 questions in 12 shapes. But 12 for one student and I have 4 so I have 48 shapes to do. it's so hard to do :( because I have about 9 round and there is 9x48=432 shapes i have to do.
My hope is the way to replace old questions for new questions easil. I'm thinking about the solution that use vba. each question will be put in a variable from a1 to a12, and a shape will get question from a1 to a12 and display. so I will just type the question in the textbox (vba) and click! is it possilbe? is there another way better to do?

ntd252
06-16-2015, 06:25 PM
and my language is vietnamese, not supported in vba code, but can be typed in the textbox (vba)

ntd252
06-19-2015, 06:25 AM
Oh I find an idea! each question is in a textbox shape (on a slide - not for play game), and I will get text from each shape and display in my shape on the slide which is played). So my code is



Public a(4) As Variant


Sub inputquestion()
a(0) = Slide3.Shapes("TextBox 8").TextFrame.TextRange.Text
a(1) = Slide3.Shapes("TextBox 9").TextFrame.TextRange.Text
a(2) = Slide3.Shapes("TextBox 10").TextFrame.TextRange.Text
a(3) = Slide3.Shapes("TextBox 11").TextFrame.TextRange.Text
a(4) = Slide3.Shapes("TextBox 12").TextFrame.TextRange.Text
Slide4.Shapes("TextBox 3").TextFrame.TextRange.Text = a(0)
End Sub



note that the line "Slide4.Shapes("TextBox 3").TextFrame.TextRange.Text = a(0)" for displaying the first question, in next questions, I use a(i), and I need to set it as public
But it doesnt work.
I try a normal variable and it works, but for an array it doesn't
Is the code correct?

ntd252
01-08-2016, 06:53 AM
Hello every body! Sorry for another problem!
I use TextBox Shape to display the score of the game. I have some animations before the game starts, when these animations finish, the game starts and each correct answer I click an button to crease to score, but when i click, all those animations runs again. Each time I click, they runs again.
What cause that?