Consulting

Results 1 to 18 of 18

Thread: Problem in adding picture to label in Powerpoint 2010

  1. #1
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location

    Problem in adding picture to label in Powerpoint 2010

    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 !

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    I usually put a no-fill textbox on the image
    Attached Images Attached Images
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location
    Oh it's great! How can you do? I cant edit shape for TextBox

  4. #4
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location
    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.

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Use a normal textbox. You can still change the score.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    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
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  7. #7
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location
    It works as I want. Thanks a lot!
    Can I get text (players' name) like the score on another textbox?

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  9. #9
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location
    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?
    Attached Files Attached Files

  10. #10
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location
    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?

  11. #11
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    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("TextBo x 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("TextBo x 5").OLEFormat.Object.Text
    Attached Files Attached Files
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  12. #12
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    @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

    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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  13. #13
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    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
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  14. #14
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    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
    Last edited by Paul_Hossler; 05-11-2015 at 03:31 PM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  15. #15
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location
    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?

  16. #16
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location
    and my language is vietnamese, not supported in vba code, but can be typed in the textbox (vba)

  17. #17
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location
    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?

  18. #18
    VBAX Regular
    Joined
    May 2015
    Posts
    11
    Location
    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?

Posting Permissions

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