Consulting

Results 1 to 14 of 14

Thread: Solved: Creating a VBA to save presentation

  1. #1

    Unhappy Solved: Creating a VBA to save presentation

    I have struggled for two days to get a presentation to save using VBA. I get multiple error messages that I don't understand and have googled everyway I can think. Basically, I have a macro that copies an excel spreadsheet into powerpoint using a VBA in Excel 2007 and now I want it to save the presentation when it is done. The program does a loop until active cell is empty then it exits. I want it to save the document when the loop is done.



    Sub Copytoppt()


    Do Until IsEmpty(ActiveCell)

    There are a whole lot of commands inside the loop and they work. They were copied from a post inside this website -
    Export Excel range or Excel chart to PowerPoint (linked or unlinked)
    I just added a loop b/c the one sheet I copy changes 13 times and creates 13 slides in presentation.

    ActiveCell.Offset(0, 1).Select

    Loop

    Here is where I want it to save. The loop is done, my 13 slides are created and I want to save presentation as powerpoint 2003 (.ppt). This VBA is saved in Excel 2007 if that matters.


    End Sub

    I appreciate any help I can get. I have spun my wheels for over 10 hours.

  2. #2
    VBAX Contributor
    Joined
    May 2008
    Posts
    198
    Location
    Is this what you are looking for?
    [vba]oPres.SaveAs filepath, ppSaveAsPresentation[/vba]
    oPres = the presentation you are saving (Application.ActivePresentation if you are saving the current file)
    filePath = the full path (with filename) that you are saving the file to.


    example:
    [vba]application.ActivePresentation.SaveAs "C:\Documents and Settings\MyName\My Documents\Test.ppt", ppSaveAsPresentation
    [/vba]

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Cosmo, I don't have any test materials, but since it's an Excel 2007 macro that's running, wouldn't Application in

    [vba]
    application.ActivePresentation.SaveAs
    [/vba]

    apply to Excel?

    cmoore -- how are you opening PP, manually or is your Excel macro using CreateObject?


    Paul

  4. #4
    The only thing I have open is an Excel document and the VBA opens a powerpoint presentation then copies my sheet as a picture into a new slide (there are 13 variations to this one sheet = 13 slides).

    When I use the above .SaveAs I get this message:

    Run-time error '438':
    Object doesn't support this property or method

    I have googled this error but do not understand how to fix it.

  5. #5
    VBAX Contributor
    Joined
    May 2008
    Posts
    198
    Location
    Sorry, Hadn't read that you were coming from Excel. You won't be able to use 'ppSaveAsPresentation' or 'application.activepresentation', but you should be able to Do you have a reference to the PowerPoint application in your excel document? Assuming that you do, and it's named "PPTApp", would this work:
    [VBA]
    PPTApp.SaveAs filepath, 1
    [/VBA]

  6. #6
    This now gives me the error message -
    Compile error:
    Method or data memeber not found.
    And it highlights the word SaveAs in your post.

    I really appreciate your assistance...I think we are getting closer.

  7. #7
    VBAX Contributor
    Joined
    May 2008
    Posts
    198
    Location
    Quote Originally Posted by cmoore3984
    This now gives me the error message -
    Compile error:
    Method or data memeber not found.
    And it highlights the word SaveAs in your post.

    I really appreciate your assistance...I think we are getting closer.

  8. #8
    VBAX Contributor
    Joined
    May 2008
    Posts
    198
    Location
    Sorry about the blank posting, having problems with this forum; it didn't post my message properly, and won't let me edit it.

    My previous code should have been:
    [VBA]
    PPTApp.ActivePresentation.SaveAs filepath, 1
    [/VBA]

  9. #9

    Smile Final outcome - Creating a VBA to save Presentation in Excel

    It worked! Thank you so much for your help! It worked and I can finally close this portion of the project.




    PPTApp.ActivePresentation.SaveAs filepath, 1

  10. #10
    Quote Originally Posted by Cosmo View Post
    example:
    [vba]application.ActivePresentation.SaveAs "C:\Documents and Settings\MyName\My Documents\Test.ppt", ppSaveAsPresentation
    [/vba]
    Hey Cosmo!!
    Can you tell me if there's a way to directly save the presentation as a macro enabled one? (using ppSaveAsPresentation saves it in .ppt format)

  11. #11
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    PowerPoint.Application.ActivePresentation.SaveAs _
    "C:\Documents and Settings\MyName\My Documents\Test.pptm", ppSaveAsOpenXMLPresentationMacroEnabled

    Should do it.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  12. #12
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Can you tell me if there's a way to directly save the presentation as a macro enabled one? (using ppSaveAsPresentation saves it in .ppt format)
    [QUOTE][
    Here is where I want it to save. The loop is done, my 13 slides are created and I want to save presentation as powerpoint 2003 (.ppt).
    /QUOTE]


    2003 or 2007 macro enabled presentation? I don't know if there's any difference in PP, but Excel has a whole bunch of options to save in earlier versions

    Paul

  13. #13
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Macro enabled presentations don't exist in 2003 Paul. It was introduced in 2007.
    Last edited by John Wilson; 03-13-2014 at 12:47 AM.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  14. #14
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Post dates, Paul, Post dates.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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