Consulting

Results 1 to 3 of 3

Thread: Perform calculation based on shape selection

  1. #1
    VBAX Newbie
    Joined
    Jan 2021
    Posts
    4
    Location

    Perform calculation based on shape selection

    Hello there. I need some help with this macros. I am trying to capture the scores from the text display on a shape and add it to another shape upon clicking a shape. I am trying to do this when in presentation mode. Here is what i have so far. Thank you

    Sub addTeamScores(oshp As Shape)
    Dim score, TeamAScore, TeamBScore As Double


    Set osld = ActivePresentation.SlideShowWindow.View.Slide

    score = CDbl(ActivePresentation.Slides(slideNum).Shapes("ScoreBoard").TextFrame.Tex tRange.Text)
    TeamAScore = CDbl(ActivePresentation.Slides(slideNum).Shapes("Score1").TextFrame.TextRan ge.Text)
    TeamBScore = CDbl(ActivePresentation.Slides(slideNum).Shapes("Score2").TextFrame.TextRan ge.Text)

    Select Case oshp.Name
    Case "Add1"
    Call addScore(score, TeamAScore)
    Case "Add2"
    Call addScore(score, TeamBScore)
    End Select

    End Sub


    Private Sub addScore(i As Double, j As Double)
    j = j + i
    i = 0
    End Sub

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,962
    Location
    See if this gets you started
    Sub addTeamScores(oshp As Shape)
    
    Dim score As Long, TeamAScore As Long, TeamBScore As Long
    Dim osld As Slide
    Set osld = ActivePresentation.SlideShowWindow.View.Slide
    
    
    'there will be an error if box is not a number
    If Not IsNumeric(osld.Shapes("ScoreBoard").TextFrame.TextRange) Then _
    osld.Shapes("ScoreBoard").TextFrame.TextRange.Text = "0"
    If Not IsNumeric(osld.Shapes("Score1").TextFrame.TextRange) Then _
    osld.Shapes("Score1").TextFrame.TextRange.Text = "0"
    If Not IsNumeric(osld.Shapes("Score2").TextFrame.TextRange) Then _
    osld.Shapes("Score2").TextFrame.TextRange.Text = "0"
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    score = CLng(osld.Shapes("ScoreBoard").TextFrame.TextRange.Text)
    TeamAScore = CLng(osld.Shapes("Score1").TextFrame.TextRange)
    TeamBScore = CLng(osld.Shapes("Score2").TextFrame.TextRange)
    Select Case oshp.Name
    Case "Add1"
    osld.Shapes("Score1").TextFrame.TextRange.Text = CStr(TeamAScore + score)
    Case "Add2"
    osld.Shapes("Score2").TextFrame.TextRange.Text = CStr(TeamBScore + score)
    End Select
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Oct 2020
    Location
    Berlin, Germany. Often vivst Ukraine for business
    Posts
    6
    Location
    Thanks

Posting Permissions

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