Consulting

Results 1 to 3 of 3

Thread: VBA/Powerpoint Help Needed... auto populating a text box!

  1. #1

    Question VBA/Powerpoint Help Needed... auto populating a text box!

    Hi All, it's been a LONG time since I did any VBA coding and I've never tried in Powerpoint. I'm trying to write two macros with the ultimate goal of upadting a text field on each page of the presentation with the text value that the user has inputted into an input box. Please can anyone help me? Also, any suggestions for good VBA courses or books would be great! Thanks Rachel.

    Here's what I'm trying to do at each step and what I've got so far:

    Macro 1:
    1. Select shape (text box) on slide 2
    2. Call it "watermark"
    3. Go onto the next side and repeat until all slides have been done

    Macro 2:
    1. Go to slide 2
    2. Find the text box called "watermark"
    3. Overwrite the existing text with whatever the user types into the input box
    4. Go onto the next side and repeat until all slides have been done

    For Macro 1 I have used:
    Sub NameShape()
    Dim Name$
    On Error GoTo AbortNameShape
    If ActiveWindow.Selection.ShapeRange.Count = 0 Then
    MsgBox "No Shapes Selected"
    Exit Sub
    End If
    Name$ = ActiveWindow.Selection.ShapeRange(1).Name
    Name$ = InputBox$("Give this shape a name", "Shape Name", Name$)
    If Name$ <> "" Then
    ActiveWindow.Selection.ShapeRange(1).Name = Name$
    End If
    Exit Sub
    AbortNameShape:
    MsgBox Err.Description
    End Sub

    For macro 2, I've got as far as:

    Sub Watermark()
    Dim strResponse As String
    strResponse = InputBox("Enter CDSID for Watermark")
    ActivePresentation.Slides(1).Shapes("watermark").TextFrame.TextRange.Text = strResponse
    End Sub

  2. #2

    Solution - Bit rough, but it works!

    So I came up with a solution - it's not perfect, but it does the job. Any improvements are very welcome though. Thanks Rachel

    Macro 1:

    Sub NameShape()

    Dim Name$

    On Error GoTo AbortNameShape

    If ActiveWindow.Selection.ShapeRange.Count = 0 Then

    MsgBox "No Shapes Selected"

    Exit Sub

    End If



    Name$ = ActiveWindow.Selection.ShapeRange(1).Name

    Name$ = InputBox$("Give this shape a name", "Shape Name", Name$)

    If Name$ <> "" Then

    ActiveWindow.Selection.ShapeRange(1).Name = Name$

    End If
    Exit Sub

    AbortNameShape:
    MsgBox Err.Description

    Macro 2:

    End Sub
    Sub Watermark()
    Dim strResponse As String
    'Dim Sl As Slide
    'Dim i As Integer

    strResponse = InputBox("Enter CDSID for Watermark")

    'ActivePresentation.Slides(1).Select
    'ActivePresentation.Slides.Count

    'With ActivePresentation.Slides.Range

    'For Each Sl In ActivePresentation.Slides
    'If ActivePresentation.Slides.Count >= 1 Then

    'For i = 2 To ActivePresentation.Slides.Count

    ActivePresentation.Slides(2).Shapes("watermark").TextFrame.TextRange.Text = strResponse
    ActivePresentation.Slides(3).Shapes("watermark").TextFrame.TextRange.Text = strResponse
    ActivePresentation.Slides(4).Shapes("watermark").TextFrame.TextRange.Text = strResponse
    ActivePresentation.Slides(5).Shapes("watermark").TextFrame.TextRange.Text = strResponse
    ActivePresentation.Slides(6).Shapes("watermark").TextFrame.TextRange.Text = strResponse
    ActivePresentation.Slides(7).Shapes("watermark").TextFrame.TextRange.Text = strResponse

    'Next Sl
    'End With
    End Sub

  3. #3
    VBAX Regular
    Joined
    Nov 2012
    Location
    Alaska
    Posts
    22
    Location
    on slide one of my quiz the person taking the test enters their name in a textbox then they start the quiz. but on the certificate slide there is a textbox for their name it carried over from slide one. how can i do 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
  •