• Make a new ppt from larger ppt (ppt xp, w2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Make a new ppt from larger ppt (ppt xp, w2000)

    Author
    Topic
    #366368

    I have a large ppt, large.ppt. It has 100 slides. I want to define several sections in the slides, like section1 = slides 1-5, section 2 = slides 6-14, section 3=slides 15-17…

    Then after the sections are all picked i want to delete the “other” slides that aren’t picked and save them the “picked” ones as a different filename.

    For instance, if they choose section 1 and section 3, they will get slides 1-5 and slides 15-17 in a new ppt. The new.ppt will have 8 slides in it. I am putting the code in the large.ppt. Can anyone please help me with a start to vba code. thanks much

    Viewing 1 reply thread
    Author
    Replies
    • #568013

      As a starting point, it seems you have a couple of approaches for building the new presentation: additive or subtractive (i.e. create a new empty presentation and add the necessary slides into it, or make a copy of the existing presentation and then delete from it only those slides that are not wanted in the new presentation).

      A starting point for the latter would be something like:

      Public Sub TestCreateNewSubPres()
      Dim OrigPres As Presentation
      Dim NewPres As Presentation

      Set OrigPres = ActivePresentation
      OrigPres.Slides.Range.Copy
      Set NewPres = Presentations.Add
      NewPres.Slides.Paste
      NewPres.Slides.Range(Array(20, 19, 18)).Delete
      ‘etc. deleting additional slides as necessary

      Set OrigPres = Nothing
      Set NewPres = Nothing
      End Sub

      (deleting from the last toward the first to avoid index errors)
      There’s probably a more efficient way to do the above, such as NewPres.SaveAs, but I’m sticking to a simple method as I don’t really know PPT!

      What’s likely to be the two tricky issues though:

      What interface do you provide the user to make the selection? – hard to see how you avoid creating a userform here.

      How flexible do the section/ slide ranges definitiions need to be? – i.e. you can create a userform with checkboxes for sections 1 through 5, and put code behind the userform defining section 1 as a range from slides 1-5 etc., but if you ever want to redefine the sections, you’d need to change the slide numbers in the code as well.

      A start, anyway.

      Gary

    • #568052

      Why use VBA? It’s very ugly! Can’t you just use slide sorter view, lasso or shift-click the slides you want and copy them to a new presentation? –Sam

      • #568067

        <>?? evilgrin

        But seriously, suppose you have a presentation with 100 slides divided into 20 sections. Copying from the slide sorter view, clicking in the new presentation, pasting, clicking back to the original presentation, copying the next range of slides etc, repeat up to 20 times – that’s a lot more work than unchecking some check boxes on a userform and clicking OK, no?

        (Besides, I never do PPT VBA, and it’s fun!) laugh

        Gary

        • #568121


          that’s a lot more work than unchecking

          I don’t think so, unless you simplified presentations for a living. By the time you created a decent user-interface, you could have done 1000’s of slides in sorter view.


          > VBA …. ugly

          Excel object model love
          Word object model puke
          PoPo object model

          • #568173

            Gee, take away a guy’s fun!.. surrender
            Love those illustrations. laugh

            But one last try – this scenario:

            Our friend, in the sales department’s central office, has created a 100-slide PowerPoint sales presentation, which is to be used by a couple of dozen sales reps when visiting clients. For each client, the sales rep wants to tailor the presentation, and eliminate those slides which are not relevant to that client or that pitch.

            Each sales rep visits say five clients a day. That’s something like 800 presentation-editing exercises done by the sales reps, each week, week after week. By having a userform, you’re saving the sales reps an aggregate amount of time that might be significant – less time sorting slides, more time with the clients.

            n that scenario (which I have no idea resembles the current case), the time invested in building and maintaining the userform would be worth it, I think.
            No go? – still too ugly? (it resembles a lot of what I do for a living…) laugh

            Gary

            • #568194

              hmmm thanks for all the input. It is exactly like Gary’s scenario. I need it VERY simple, my users will not be able to cut out the slides they don’t want etc. from the slide sorter. They need a simple user form to come up that gives them only the “sections” they ask for.

              I’m creating a “wizard” user form that asks them what “sections” they want and when they click on OK they get those slides in a new ppt. Gary, thanks for the code. How or where do I define the sections? How do i way that slides 1-5 will be “section1” and add those when they click on OK? thanks for your help

              I’m also thinking of 2 listboxes and moving from 1 to the other to “build” the new presentation. That way they can move up and move down their selections in the rightside listbox to order them in the way they want. Any, vba help is greatly appreciated.

            • #568241

              Gary, you’re exactly correct, this is a perfect example of a need for a userform. It’s simple, fast, and you can add checks to make sure they always include required slides. Still ugly to develop! –Sam drop

            • #568252

              Edited by Gary Frieder on 04-Feb-02 21:35.

              Fortunately(??), I’m home sick tonight, or wouldn’t have had time to do this.
              But it was a fun project – most of the work was with the userform which is applicable to other apps too.

              So jha, here is working example of what you’ve described – you should be able to connect the dots and tailor it for your presentation.
              There is one little bit of flaky behavior with the userform button to move items up in the list – it doesn’t seem to want to behave.

              Open the attached ppt., save it to your local machine, then open it in PPT. You should see a toolbar called “Create New Presentation”.

              NOTE: Jefferson Scher has come to the rescue and suggested I attach a zipped version of the ppt file – great idea – hope this works.

              Gary

            • #574909

              this is soooooo totally cool! i can’t thank you enough.

              the move up and down works for me

            • #575668

              hi, it’s me again. Everything is working well. I’m able to add different master templates to the “newpres”. After the user selects the sections they want and selects the template design they like, i need to add a client logo to their presentation. I want to add it to the master page so it appears in the bottom righthand corner of every slide.

              I have the user put the client’s logo file in c:logos and then i have them enter the name of it into a textbox in my app’s form, txtClientLogo.text. How do I get to the slide master of the template that is chosen and insert the logo in a specific position? I’ve tried to do it using the macro reader but I can’t seem to program it for any file that is entered in the txtClientLogo.text box and located in c:logos.

              Can you give me some guidance. Thank you

            • #575676

              Hi jha,

              You’re exposing my ignorance of PPT – beyond having written a couple of macros. Not knowing the steps one would take – in the user interface – to select the template, and set up a slide master in a template, it’s hard to know what steps to take to do this via code.
              A little poking around though produced code like this – don’t know if it is relevant to this situation:

              ActivePresentation.SlideMaster.Shapes.AddPicture

              – have a look at the VBA Help for the AddPicture method – you need to provide it with a filename (and path). There are also arguments for Top and Left which may let you control the location which the logo will get placed on the slide.

              If this doesn’t fill the bill, then post back with a description of the steps required – in the user interface – to set up the master slide in a template – that might provide guidance on what needs to be done via code.

              Hope this helps,
              Gary

            • #575731

              It’s exactly like Gary says. Record a macro to insert the logo and move it where you want it. Then add the IncrementLeft and IncrementTop to the Left and Top so that it goes in the right location and delete all but the AddPicture statement. Same thing works for the TitleMaster if you need it. Below is an example. HTH –Sam

              Sub Macro1()
                  ActivePresentation.SlideMaster.Shapes.AddPicture _
                      FileName:="C:Your PathYour File.jpg", _
                      LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
                      Left:=550, Top:=350, Width:=99, Height:=99
              End Sub
    Viewing 1 reply thread
    Reply To: Make a new ppt from larger ppt (ppt xp, w2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: