2

I have a Macro Enabled PowerPoint document(PPTM) that I would like to add functionality to "Export" to a non-Macro enabled document(PPTX). I have written the following VBA code to accomplish this:

'Default selected file type PPTX
Dim selected As String: selected = Application.FileDialog(msoFileDialogSaveAs).Show()
Dim filePath As String

If selected <> 0 Then
    filePath = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)
    ActivePresentation.SaveCopyAs fileName:=filePath, FileFormat:=ppSaveAsOpenXMLPresentation
End If

This works correctly and saves the document without any of the associated VBA code, however I've included in my source PPTM file a customUI Menu which I would like to remove as well, as the ribbon tab links to the various VBA functions which I have removed.

How can I save to a PPTX without the included CustomUI menu? Is there a way to "remove" the CustomUI menu with VBA(really doesn't look like it, at least in Excel Hide/Show), or can it be hidden without placing VBA method calls with the CustomUI's Load Event(such as this Example)?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
David Rogers
  • 2,601
  • 4
  • 39
  • 84
  • 1
    Interesting; I never knew that the PPTX would include RibbonX customizations. Does your presentation include any content that would be trashed by saving as PPT rather than PPTX? That'd be one way of cleaning out the custom UI code. To make it more entertaining, I don't think including VBA method calls would help, in that the saved PPTX would not be permitted to include VBA to call on. – Steve Rindsberg Feb 02 '16 at 04:00
  • @Steve, that's a very interesting work around, and may do the trick for the project that I'm currently working on since the VBA macro methods are all triggered from button clicks in the customUI elements, but more broadly I'm not sure that this is good long term general solution as the VBA code is still present in a PPT file. It's like I need to save it as a PPT then as a PPTX, don't think that can be done though... – David Rogers Feb 02 '16 at 15:25
  • Thinking it out a step further: Save as PPT (rids the file of the RibbonX code) then save again as PPTX (rids it of the VBA). And I agree that in this case "interesting" might be considered a synonym for "clumsy". I've asked someone I know at MS if retaining the RibbonX in this situation is deliberate or an oversight. No answer just yet. – Steve Rindsberg Feb 02 '16 at 15:31
  • I actually had a conversation with my coworkers about this before posting, I was going to originally ask that exact question in my post but I believe the reason they don't remove it is because you can call non VBA Macro methods from the ribbon such as the examples provided here: http://gregmaxey.mvps.org/word_tip_pages/customize_ribbon_main.html – David Rogers Feb 02 '16 at 15:41
  • Yep, whether or not this is an oversight, the MS folks I talked with felt that removing the RibbonX w/o user's consent might be considered a data-loss situation, which they're anxious to avoid. – Steve Rindsberg Feb 03 '16 at 16:34

1 Answers1

2

In theory it should be possible to save the pptm as a pptx file (removing the VBA code), close it, rename it .zip, delete the customUI folder (which contains customUI.xml) from the zip and then rename it back to .pptx

I tried this manually and it worked.

Ron de Bruin has some VBA ZIP code examples here : http://www.rondebruin.nl/win/s7/win001.htm

Jamie Garroch - MVP
  • 2,839
  • 2
  • 16
  • 24
  • I agree that this should work in theory, though, I haven't implemented this as a solution, I eventually simply saved my PPTM as PPT(as @SteveRindsberg suggested), thus removing both the ribbon but not the VBA code. – David Rogers Apr 05 '16 at 14:18