Wednesday, January 30, 2013

Powerpoint 2007 - saving to *.PPTX

Ran into a hiccup in powerpoint 2007 when creating an automated import for navis works xml files- you can't save to pptx, and I didn't want the added macro stuff to go with each new file - so I dug and found this trick at +help.wugnet.com

Sub TestSaveas()
  SaveAs "c:\somefilepath\"
End sub

Private Sub SaveAs(fp As String)
   Dim dlgSaveAs As FileDialog
   Dim strMyFile As String

   Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
   With dlgSaveAs
       .InitialFileName = fp
       If .Show = -1 Then
           strMyFile = .SelectedItems(1)
           Application.ActivePresentation.SaveAs strMyFile
           'MsgBox strMyFile
           ''-- save your file to strMyFile here
       Else
           MsgBox "File not saved"
       End If
   End With
   dlgSaveAs.Execute
   Set dlgSaveAs = Nothing
End Sub

The execute is critical (and missing off microsoft's site) otherwise it throws a DLL error.