Help a newby invoke sub routines

Colin Wood 0 Reputation points
2023-04-12T16:41:57.7966667+00:00

Screenshot 2023-04-12 174253

I have some code that works but fails when I try to call it from within another subroutine. I'm still at the very early stages of learning VBA so any help or advice would be great.. The code below is in PowerPoint. I'm trying to run a quiz question on a slide that allows the user to choose the color of shapes within a diagram on the master slide if the correct answers is given. The sub routine CheckAnswer works in isolation and the sub routine ChooseColor also works in isolation - but calling ChooseColor from within CheckAnswer does not work. Option Explicit Sub CheckAnswer() 'Finding the current slide number during slideshow mode Dim CurrentSlideNo As Integer CurrentSlideNo = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex 'AA is the name of a normal text box on the slide with the attempted answer. CA is the name of an activeX text box the user types in during the presentation If UCase(ActivePresentation.Slides(CurrentSlideNo).Shapes("AA").OLEFormat.Object.Value) = UCase(ActivePresentation.Slides(CurrentSlideNo).Shapes("CA").TextFrame.TextRange) Then MsgBox "Correct Answer, now choose the color you want to use" ChooseColor Else MsgBox "Wrong Answer. Try Again!" End If End Sub Sub ChooseColor(oSh As Shape) Dim RGB As Variant RGB = oSh.Fill.ForeColor.RGB ActivePresentation.SlideMaster.Shapes("Master1").Fill.ForeColor.RGB = RGB End Sub

PowerPoint Management
PowerPoint Management
PowerPoint: A family of Microsoft presentation graphics products that offer tools for creating presentations and adding graphic effects like multimedia objects and special effects with text.Management: The act or process of organizing, handling, directing or controlling something.
224 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. John Korchok 5,156 Reputation points
    2023-04-13T16:03:19.2133333+00:00

    When the Sub is in the same module, use: Call Choosecolor You'll have other questions after you do that. Please start a new thread for each question. When posting code, please post the code listing, not a screen shot. No one wants to re-key your macro to test it.

    0 comments No comments