none
Powerpoint Addon keeps crashing RRS feed

  • Question

  • Can someone help me with this. Trying to add an addon. Using 2013. I open pp and added the developer section. Added in the code below then saved it as a macro enabled power point. I then saved it again as a powerpoint addon .

    Its supposed to create a button that when you click it executes a macro that pulls out the notes sections from powerpoint slides and saves in a location you pick. When I try to add the addon though it fails immediately and powerpoint asks do I want to disable it in order for it to open. When I debug it though there are no errors so perhaps I am just adding it incorrectly. Below is the addon.

    Sub Auto_Open()
        Dim oToolbar As CommandBar
        Dim oButton As CommandBarButton
        Dim MyToolbar As String

        ' Give the toolbar a name
        MyToolbar = "Moo Tools"

        On Error Resume Next
        ' so that it doesn't stop on the next line if the toolbar's already there

        ' Create the toolbar; PowerPoint will error if it already exists
        Set oToolbar = CommandBars.Add(Name:=MyToolbar, _
            Position:=msoBarFloating, Temporary:=True)
        If Err.Number <> 0 Then
              ' The toolbar's already there, so we have nothing to do
              Exit Sub
        End If

        On Error GoTo ErrorHandler

        ' Now add a button to the new toolbar
        Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)

        ' And set some of the button's properties

        With oButton

             .DescriptionText = "Export slide notes"
              'Tooltip text when mouse if placed over button

             .Caption = "Export Notes"
             'Text if Text in Icon is chosen

             .OnAction = "Button1"
              'Runs the Sub Button1() code when clicked

             .Style = msoButtonIcon
              ' Button displays as icon, not text or both

             .FaceId = 52
              ' chooses icon #52 from the available Office icons

        End With

        ' Repeat the above for as many more buttons as you need to add
        ' Be sure to change the .OnAction property at least for each new button

        ' You can set the toolbar position and visibility here if you like
        ' By default, it'll be visible when created. Position will be ignored in PPT 2007 and later
        oToolbar.Top = 150
        oToolbar.Left = 150
        oToolbar.Visible = True

    NormalExit:
        Exit Sub   ' so it doesn't go on to run the errorhandler code

    ErrorHandler:
         'Just in case there is an error
         MsgBox Err.Number & vbCrLf & Err.Description
         Resume NormalExit:
    End Sub

    Sub Button1()
    ' This code will run when you click Button 1 added above
    ' Add a similar subroutine for each additional button you create on the toolbar
        ' This is just some silly example code.
        ' You'd put your real working code here to do whatever
        ' it is that you want to do
        Call ExportNotesText
    End Sub

    Sub ExportNotesText()

        Dim oSlides As Slides
        Dim oSl As Slide
        Dim oSh As Shape
        Dim strNotesText As String
        Dim strFileName As String
        Dim intFileNum As Integer
        Dim lngReturn As Long

        ' Get a filename to store the collected text
        strFileLoc = "C:\Users\Carito\Documents\PPT Notes\"
        strFile = InputBox("Enter the name of the file ending in .txt", "Will save here: C:\Users\Carito\Documents\PPT Notes\")
        strFileName = strFileLoc & strFile


        ' did user cancel?
        If strFileName = "" Then
            Exit Sub
        End If

        ' is the path valid?  crude but effective test:  try to create the file.
        intFileNum = FreeFile()
        On Error Resume Next
        Open strFileName For Output As intFileNum
        If Err.Number <> 0 Then     ' we have a problem
            MsgBox "Couldn't create the file: " & strFileName & vbCrLf _
                & "Please try again."
            Exit Sub
        End If
        Close #intFileNum  ' temporarily

        ' Get the notes text
        Set oSlides = ActivePresentation.Slides
        For Each oSl In oSlides
            For Each oSh In oSl.NotesPage.Shapes
            If oSh.PlaceholderFormat.Type = ppPlaceholderBody Then
                If oSh.HasTextFrame Then
                    If oSh.TextFrame.HasText Then
                        strNotesText = strNotesText & "Slide: " & CStr(oSl.SlideIndex) & vbCrLf _
                        & oSh.TextFrame.TextRange.Text & vbCrLf & vbCrLf
                    End If
                End If
            End If
            Next oSh
        Next oSl

        ' now write the text to file
        Open strFileName For Output As intFileNum
        Print #intFileNum, strNotesText
        Close #intFileNum

        ' show what we've done
        lngReturn = Shell("NOTEPAD.EXE " & strFileName, vbNormalFocus)

    End Sub

    • Moved by George123345 Monday, January 27, 2014 5:34 AM VBA
    Sunday, January 26, 2014 1:40 AM

Answers

  • Do not use CommandBars.Add (old style) in 2013. Use XML to build new Menu.

    You can download "Custom UI Editor For Microsoft Office"

    Ron describe what is all about.

    p.s.

     You cant modyf old PP add-in (MS trick). You should build and save new one every time you have new code ideas.


    Oskar Shon, Office System MVP - www.VBATools.pl
    if Helpful; Answer when a problem solved

    Monday, January 27, 2014 8:37 AM
  • Hi,

    According to your description, you want to add a VBA macro as a PowerPoint Add-in.

    I try to add you code as a VBA module to a PowerPoint 2013 document in DEVELOPER Tab->Visual Basic Button->Insert Module. After executing the code, it successfully creates a button in my Add-INS Tab as below. When I click the button, it will pop up a notes sections from PowerPoint slides and saves in a location you pick as you said. So I think there is no issue with the code.
     
    To add this module as a PowerPoint Add-in, we just need to save this Presentation as a PowerPoint 97-2003 Add-In (*.ppa) instead of a PowerPoint Macro-Enable Presentation(*.pptm). If you save the document as pptm format, the add-in can only be loaded in this document.

    After saving the module as a ppa file, we could add this file as an Add-In into the PowerPoint Application in DEVELOPER tab-> Add-Ins button as followed.

    In this way, after loading it, we could found a button in Add-INS tab. When you open a new .ppt document, the Add-in will display unless you unload it.

    You could check the steps above and follow it to see whether the issue exists.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 27, 2014 10:13 AM
    Moderator

All replies

  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Office ,the issue is more related to Word coding/programing, I'll move your question to the MSDN forum

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=officegeneral&filter=alltypes&sort=lastpostdesc

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    George Zhao
    TechNet Community Support

    Monday, January 27, 2014 5:34 AM
  • Do not use CommandBars.Add (old style) in 2013. Use XML to build new Menu.

    You can download "Custom UI Editor For Microsoft Office"

    Ron describe what is all about.

    p.s.

     You cant modyf old PP add-in (MS trick). You should build and save new one every time you have new code ideas.


    Oskar Shon, Office System MVP - www.VBATools.pl
    if Helpful; Answer when a problem solved

    Monday, January 27, 2014 8:37 AM
  • Hi,

    According to your description, you want to add a VBA macro as a PowerPoint Add-in.

    I try to add you code as a VBA module to a PowerPoint 2013 document in DEVELOPER Tab->Visual Basic Button->Insert Module. After executing the code, it successfully creates a button in my Add-INS Tab as below. When I click the button, it will pop up a notes sections from PowerPoint slides and saves in a location you pick as you said. So I think there is no issue with the code.
     
    To add this module as a PowerPoint Add-in, we just need to save this Presentation as a PowerPoint 97-2003 Add-In (*.ppa) instead of a PowerPoint Macro-Enable Presentation(*.pptm). If you save the document as pptm format, the add-in can only be loaded in this document.

    After saving the module as a ppa file, we could add this file as an Add-In into the PowerPoint Application in DEVELOPER tab-> Add-Ins button as followed.

    In this way, after loading it, we could found a button in Add-INS tab. When you open a new .ppt document, the Add-in will display unless you unload it.

    You could check the steps above and follow it to see whether the issue exists.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 27, 2014 10:13 AM
    Moderator
  • Thanks. I thought I tried exactly what you showed, saving as the 2003 format and it worked great until I closed PP completely and re-opened it. I think like Oskar is saying 2013 doesnt like the "CommandBars.Add (old style) in 2013". When I tried the same steps in 2003 it worked great.

    I did find a suitable workaround from another MS posting but I dont like it. It's a little convoluted and involves having an addon running hidden to make the one I want to use available all the time. I will take a look at Rons site provided by Oskar above as it seems fairly straight forward to try.

    Monday, January 27, 2014 2:03 PM