Consulting

Results 1 to 4 of 4

Thread: Displaying user assigned values

  1. #1
    VBAX Regular
    Joined
    Aug 2009
    Posts
    7
    Location

    Displaying user assigned values

    Hello,
    A couple of very basic questions for a VBA newbie.

    If there is user input, say with the following macro,

    Sub Getname()
    userName = InputBox(Prompt:="Enter the name you want to be addressed by:")
    MsgBox ("Welcome to the presentation, " & userName)
    End Sub

    How can I display the value of userName in a subsequent slide?
    Also, in the event of multiple macros assigning variables via user input, how can I calculate the product of these variables and display the result on a subsequent slide?

    Thanks!

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Sopposing you have a shape on SLIDE 3 named nameShape

    Try

    Sub Getname()
    Dim UserName As String ' always declare variables - you will need to for the next part
    UserName = InputBox(Prompt:="Enter the name you want to be addressed by:")
    MsgBox ("Welcome to the presentation, " & UserName)
    With ActivePresentation.Slides(3).Shapes("nameShape").TextFrame.TextRange
    .Text = "I knew you were coming " & UserName
    End With
    End Sub
    Make sure the shape exists on slide 3 or it will error.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Aug 2009
    Posts
    7
    Location
    Great, thanks.
    One followup - How would you clear the values that appear via the ActivePresentation? When I close the PowerPoint and reopen it, the old values still appear in the shapes.

    Thanks again!

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    IF you named the shape as I suggested try this:

    Sub OnSlideShowTerminate(SW As SlideShowWindow)
    Dim osld As Slide
    On Error Resume Next
    For Each osld In SW.Parent.Slides
    osld.Shapes("nameShape").TextFrame.DeleteText
    Next
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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