Consulting

Results 1 to 1 of 1

Thread: Resetting a Presentation

  1. #1
    VBAX Newbie
    Joined
    May 2021
    Posts
    2
    Location

    Resetting a Presentation

    Greetings,

    I am attempting to create a user preference survey for computer services. I chose PowerPoint as I would be able to engage and hopefully hold the interest of the prospective client. This is not a mass mailing. Rather, it is a one on one session. I have figured out how to navigate through the presentation. Furthermore, it seems that when input is entered in the presentation, it is saved. That is what I want.

    At the end of the survey, I would like to save the presentation and make it read only to keep the preferences entered by the client. I would share a fresh presentation on OneDrive for other clients.

    I would also like to be able to give the client the option to reset the form if they wish. I am struggling with this. I will have ActiveX: textboxes, command buttons, checkboxes, optionbuttons and comboboxes. I would like to be able to reset these to defaults: textbox = "", checkbox = unchecked, optionbuttons = unchecked and comboboxes = 'Select'.

    I took a stab at resetting the optionbuttons. Here is the code:

    Private Sub xbutton_reset_Click()

    Dim sl As Slide
    Dim sh As Shape

    For Each sl In ActivePresentation.Slides
    For Each sh In sl.Shapes
    If sh.Type = msoOLEControlObject Then
    If sh.OLEFormat.ProgID = "Forms.OptionButton.1" Then
    MsgBox sh.Name 'the msgbox printed optionbutton names only
    'what code do I put here to set the value property of the option buttons to false?
    End If
    End If

    Next sh
    Next sl

    End Sub

    I was able to loop through all of the shapes in the presentation, identify the optionbuttons, and print the names of the buttons in the presentation. But I couldn't figure out how to set their value property to False.

    I would also like to reset the rest of the controls. I was thinking about either a sub that took a shape object as an argument and then either case statements or if's to reset the values. I could always create a Sub for each control type as well.

    I am rather new to VBA programming and am really struggling to cast a Shape object to specific controls in order to access their properties and methods. I would be very grateful if you could share your talent and experience with me.

    Thanks,
    Graham

    EDIT:
    I tripped over the solution to my question in another thread in this forum. I couldn't put in the link (apologies to moderator - newbie mistake). I'd like to thank Andy Pope for his answer and messhino for asking the right question. It was this code that I was missing:

    If TypeName(sh.OLEFormat.Object) = "OptionButton" Then
    sh.OLEFormat.Object.Value = False

    If moderator sees this post, could you let me know how to give kudos to posters.

    Thanks all,
    Graham
    Last edited by gfd; 05-10-2021 at 11:13 PM.

Posting Permissions

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