PDA

View Full Version : Saving error after save of newly-created document



merc1286
01-16-2018, 12:57 PM
Hi. I have a Powerpoint deck that I use as a "template" to generate new deck. The template has a bunch of slides in it with their layout all set, and a macro that does the following when run:

Creates a copy of the deck (in the background, the show flag is FALSE) with:


Dim newpres As Presentation
Set newpres = Presentations.Open(ActivePresentation.FullName, False, True, False)


It then does all of its work to change newpres. When it's done, it saves and closes newpres with the following code:


Set savename = Application.FileDialog(Type:=msoFileDialogSaveAs)
With savename
.InitialFileName = "New Chart.pptx"
If .Show = -1 Then
strMyFile = .SelectedItems(1)
newpres.SaveAs (strMyFile)
Else
MsgBox "No File Entered. Cancelling.", , "No Filename"
End If
End With
newpres.Close

The problem I'm having is that once that is done, if you make any changes to the TEMPLATE file and try to save them, you get 2 popups. The first one says "An error occurred while Powerpoint was saving the file", and the second one says "We're sorry, something went wrong that might make Powerpoint unstable. Please save your presentations and restart Powerpoint".
If I try to save the template file with a new name, it works fine. Any changes I make to the template file BEFORE I run the macro also will save fine. But once I run the macro, I get those errors unless I either save it with a new name or just close the file without saving.
Any ideas? Thanks!

Paul_Hossler
01-23-2018, 07:44 AM
Hi. I have a Powerpoint deck that I use as a "template" to generate new deck. The template has a bunch of slides in it with their layout all set, and a macro that does the following when run:


By 'Template' do you mean a POTM (real PP template file with macros) saved in your \Templates folder, or a 'regular' PPTM (PP presentation with macros) that you SaveAs and then change the copy?

John Wilson
01-23-2018, 07:48 AM
Why do you not just open the template Untitled , make any changes and then save with the new name?

merc1286
01-23-2018, 08:30 AM
By 'Template' do you mean a POTM (real PP template file with macros) saved in your \Templates folder, or a 'regular' PPTM (PP presentation with macros) that you SaveAs and then change the copy?

I mean a regular PPTM that I use as a "pseudo-template"... I make a copy of it, make some changes to the copy, and then save the copy.

merc1286
01-23-2018, 08:31 AM
Why do you not just open the template Untitled , make any changes and then save with the new name?

That might be OK, but it still is a bad form to have those error messages appear. They also appear when I make backend changes to the code, which is pretty annoying.

John Wilson
01-23-2018, 08:37 AM
So you are opening basically a copy with no name and no window. How does the file dialog know which file to save as?

merc1286
01-23-2018, 09:13 AM
So you are opening basically a copy with no name and no window. How does the file dialog know which file to save as?

I create it with the variable newpres using:


Set newpres = Presentations.Open(ActivePresentation.FullName, False, True, False)
Then I make all of the changes using the newpres variable. for example:

newpres.Slides(1).Shapes("TitleBox").TextFrame.TextRange.Text = "Management Monthly Report"

Then I use the following code to prompt the user for the save filename:


Set savename = Application.FileDialog(Type:=msoFileDialogSaveAs)
With savename
.InitialFileName = "New Chart.pptx"
If .Show = -1 Then
strMyFile = .SelectedItems(1)
newpres.SaveAs (strMyFile)
Else
MsgBox "No File Entered. Cancelling.", , "No Filename"
End If
End With
newpres.Close