Consulting

Results 1 to 7 of 7

Thread: Saving error after save of newly-created document

  1. #1
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    4
    Location

    Saving error after save of newly-created document

    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!

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    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?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Why do you not just open the template Untitled , make any changes and then save with the new name?
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  4. #4
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    4
    Location
    Quote Originally Posted by Paul_Hossler View Post
    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.

  5. #5
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    4
    Location
    Quote Originally Posted by John Wilson View Post
    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.

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    So you are opening basically a copy with no name and no window. How does the file dialog know which file to save as?
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  7. #7
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    4
    Location
    Quote Originally Posted by John Wilson View Post
    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

Posting Permissions

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