dcsimg
Results 1 to 8 of 8

Thread: Display UserForm on Open in ppt 2007

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    4

    Display UserForm on Open in ppt 2007

    Hi All

    When using MS Word 2007 I can put the following code in the ThisDocument areas in VB, which displays the userForm when the document is opended.

    Code:
    Private Sub Document_Open()
        UserForm.Show
    End Sub
    Why wont this work in Powerpoint? Is it possible for a userForm to open in Powerpoint whent he presentation is opended?

  2. #2
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,688

    Re: Display UserForm on Open in ppt 2007

    There is no "Document" in a PowerPoint presentation. Yes you can have a UserForm in PP.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Display UserForm on Open in ppt 2007

    The easiest way is to use this utility: http://skp.mvps.org/autoevents.htm

    Short of that, you need to write a PowerPoint add-in (ppa) in order to handle any initial application events. The above makes this a lot easier.

    I've never seen a need for userforms in PowerPoint myself - what functionality are you providing just out of interest?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    4

    Re: Display UserForm on Open in ppt 2007

    I have created a powerpoint presentation for the sales office which needs to be easily tailered to suit the prospect they are visiting. As such, I have created a user form whereby they can enter bespoke details, e.g. prospect name, their name etc.

    The userform macro would then run and amend any instances of the dummy text that corresponds to the txt input field.

    See code below:
    Code:
    Private Sub runUserForm_Click()
               
        Dim oSld As Slide
        Dim oShp As Shape
        Dim oTxtRng As TextRange
        Dim oTmpRng As TextRange
        'Dim strWhatReplace As String, strReplaceText As String
        
        Dim range As Integer
        Dim startTextArray(0 To 3) As String, replaceTextArray(0 To 3) As String
          
        If txtCompanyName = "" Or txtAccMan = "" Or txtISP = "" Or txtVanDriver = "" Then
            mssingInfo = 1
        End If
        
        ' Hide the form
        If mssingInfo = 1 Then
            MissingData
        Else
            ' Declare the text to be replaced
            startTextArray(0) = "rplCompanyName"
            startTextArray(1) = "rplAccountManager"
            startTextArray(2) = "rplISP"
            startTextArray(3) = "rplVanDriver"
            
            ' Declare the variables of the input fields
            replaceTextArray(0) = txtCompanyName
            replaceTextArray(1) = txtAccMan
            replaceTextArray(2) = txtISP
            replaceTextArray(3) = txtVanDriver
            
            ' Select the final array number as the range
            range = 3
            For x = 0 To range    ' modification for range
             ' go during each slides
                For Each oSld In ActivePresentation.Slides
                     ' go during each shapes and textRanges
                    For Each oShp In oSld.Shapes
                        If oShp.HasTextFrame Then
                             
                             ' replace in TextFrame
                            Set oTxtRng = oShp.TextFrame.TextRange
                            Set oTmpRng = oTxtRng.Replace( _
                            FindWhat:=startTextArray(x), _
                            Replacewhat:=replaceTextArray(x), _
                            WholeWords:=True)
                             
                            Do While Not oTmpRng Is Nothing
                                Set oTxtRng = oTxtRng.Characters _
                                (oTmpRng.Start + oTmpRng.Length, oTxtRng.Length)
                                Set oTmpRng = oTxtRng.Replace( _
                                FindWhat:=startTextArray(x), _
                                Replacewhat:=replaceTextArray(x), _
                                WholeWords:=True)
                             Loop
                        End If
                    Next oShp
                Next oSld
            Next x
        
            UserForm.Hide
        End If
        
    End Sub
    Sub MissingData()
    
        Msg = "Your form is missing data - please complete all the field marked as Required"
        MsgBox Msg, , "Missing Data"
    
    End Sub
    I have decided to advise the sales office to use ALt+F8 then Run. Much simpler for the sales office then contending with automated forms!!!!

  5. #5
    New Member
    Join Date
    Aug 2019
    Posts
    3

    Re: Display UserForm on Open in ppt 2007

    No special utility is needed.
    Simply create a user form and and this method in the powerpoint module:
    Code:
    Sub OnSlideShowPageChange() 
        Dim i As Integer 
        i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition 
        If i <> 1 Then Exit Sub ' <= Running only for the first slide.
        MsgBox "Your code goes here" 
    End Sub

  6. #6
    New Member
    Join Date
    Aug 2019
    Posts
    3

    Re: Display UserForm on Open in ppt 2007

    Quote Originally Posted by shaialo View Post
    No special utility is needed.
    Simply create a user form and add this method in the powerpoint module:
    Code:
    Sub OnSlideShowPageChange() 
        Dim i As Integer 
        i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition 
        If i <> 1 Then Exit Sub ' <= Running only for the first slide.
        MsgBox "Your code goes here" 
    End Sub
    Forgot the userForm.show:

    Code:
    Sub OnSlideShowPageChange() 
        Dim i As Integer 
        i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition 
        If i <> 1 Then Exit Sub ' <= Running only for the first slide.
        UserForm.Show
    End Sub

  7. #7
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,688

    Re: Display UserForm on Open in ppt 2007

    Quote Originally Posted by shaialo View Post
    No special utility is needed.
    Simply create a user form and and this method in the powerpoint module:
    Code:
    Sub OnSlideShowPageChange() 
        Dim i As Integer 
        i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition 
        If i <> 1 Then Exit Sub ' <= Running only for the first slide.
        MsgBox "Your code goes here" 
    End Sub
    Welcome to the forums.

    Thank you for your posts but please do not bump/reply to old threads. This one is 11 years old and the thread starter may not even be around anymore
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    New Member
    Join Date
    Aug 2019
    Posts
    3

    Re: Display UserForm on Open in ppt 2007

    Quote Originally Posted by RobDog888 View Post
    Welcome to the forums.

    Thank you for your posts but please do not bump/reply to old threads. This one is 11 years old and the thread starter may not even be around anymore
    I know... but since I was looking for solution to the same issue just recently, and I also bumped into this thread, I thought about helping others that might come across this thread too.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width