11 Replies Latest reply: Aug 20, 2014 8:34 AM by LauraS056 RSS

Export multiple objects to a single powerpoint slide

BharathBK

Can anyone provide sample code for a macro to export multiple objects into a single powerpoint slide.

 

Looks like there are no previous discussions regarding this topic.

All the discussions only tell about pasting a single object per slide.

 

I would really appreciate it, if someone sheds light on this topic.

 

Thanks,

Bharath

  • Re: Export multiple objects to a single powerpoint slide
    erich shiino

    Hi,

    I adapted DV's code from this post:

    http://community.qlik.com/message/196413#196413

     

    Sub ExportPPT

     

    ActiveDocument.ActiveSheet.FitZoomToWindow

     

    Set objPPT = CreateObject("PowerPoint.Application")

    objPPT.Visible = True

    Set objPresentation = objPPT.Presentations.Add

     

        For i = 0 To ActiveDocument.NoOfSheets - 1

       '     Set MySheet = ActiveDocument.GetSheet(i)

     

     

            Set PPSlide = objPresentation.Slides.Add(1,11)

       '     ActiveDocument.ActiveSheet.CopyBitmapToClipboard

                           ActiveDocument.GetSheetObject("CH03").CopyBitmapToClipboard

     

     

            PPSlide.Shapes.Paste

                           ActiveDocument.GetSheetObject("CH04").CopyBitmapToClipboard

     

     

            PPSlide.Shapes.Paste

     

     

        Next

     

    Set PPSlide = Nothing

    Set PPPres = Nothing

     

    End sub

     

    This will export charts CH03 and CH04

     

    Hope this helps,

     

    Erich

    • Re: Export multiple objects to a single powerpoint slide
      BharathBK

      Thanks for the prompt reply Erich.

       

      The script you posted allows me to copy objects only from my Active sheet on to a slide.

       

      But, I want to copy objects from other sheets as well.

      To do this I have tried to manually set the active sheets but in vain.

       

      Sub ExportPPT

      Set objPPT = CreateObject("PowerPoint.Application")
      objPPT.Visible = True
      Set objPresentation = objPPT.Presentations.Add(True)


      Set Sheet1= ActiveDocument.Sheets("SH04")
      Set PPSlide = objPresentation.Slides.Add(objPresentation.Slides.Count + 1,11)

      PPSlide.Shapes(1).TextFrame.TextRange.Text = "Productivity Tracking"
      Sheet1.GetSheetObject("CH34").CopyBitmapToClipboard
      PPSlide.Shapes.Paste
      Sheet1.GetSheetObject("CH05").CopyBitmapToClipboard
      PPSlide.Shapes.Paste
      Sheet1.GetSheetObject("CH35").CopyBitmapToClipboard
      PPSlide.Shapes.Paste

      Set Sheet2= ActiveDocument.Sheets("SH10")
      Set PPSlide = objPresentation.Slides.Add(objPresentation.Slides.Count + 1,11)
      PPSlide.Shapes(1).TextFrame.TextRange.Text = "Hiring"
      Sheet2.GetSheetObject("CH37").CopyBitmapToClipboard
      PPSlide.Shapes.Paste
      Sheet2.GetSheetObject("CH38").CopyBitmapToClipboard
      PPSlide.Shapes.Paste

      Set PPSlide = Nothing
      Set PPPres = Nothing

      End sub

       

      This is the error I receive.

      Object doesn't support this property or method: 'Sheet1.GetSheetObject'

       

      How can I actually select what objects I want from different sheets?

       

      I would also love to know, how I can control the positions of the objects on the slide?

      Thanks,

      BharathBK

       

       

       

      • Re: Export multiple objects to a single powerpoint slide
        erich shiino

        Are the objects in those sheets minimized? When I tried before, it didn't work.

         

        You can try to activate the sheet before copying the object:

        ActiveDocument.ActivateSheetByID "SH01"

        It may also be necessary to restore the object (if it is minimized) with something like this:

        ActiveDocument.GetSheetObject("CH03").Activate

         

        I did a quick search, trying to control how to position the object when it is pasted, but I couldn't find a way. It would depend on the syntax provided by powerpoint itself...

         

        Hope this helps,

         

        Erich

        • Re: Export multiple objects to a single powerpoint slide
          Suresh Baabu

          Hello Erich,

           

          I'm Not sure if you have fixed the issue by now.

           

          You can use the follwing the positon the objects when you place them on PPT. Set values for ( .Left, .top, .width, .height)

           

          ActiveDocument.GetSheetObject("P2T2").CopyBitmapToClipboard
          with PPSlide.Shapes.Paste
          .Left = 150
          .top = 350
          .width=50
          .height=90
          end with

           

          Hope it helps you!!!

           

          I need your help in fixing my issue with PPT. I have 2 objects, one on 1st sheet and 2nd on the next sheet. I was able to export the object on 1st sheet to the ppt and could not export the 2nd one, Beacuse it was not the  Active sheet. I tried You method above but I could not get that. Could you please help me fixing this issue?

           

        • Re: Export multiple objects to a single powerpoint slide
          tduroyon

          Hi,

          A 720 width will give you objects of the maximum width of the slide, and as it is grow the bitmap proportionally, you end up with a clean mage or table...

          Cheers

    • Re: Export multiple objects to a single powerpoint slide
      akumar.c

      Hi Erich,

       

      Do you have any macro for

       

      Export multiple Sheets as a image to a single powerpoint slides.

       

      Suppose I have an QV Application and I want to send all the sheets as a image to multiple Slide in a Single PPT.

       

      Please help me on this.

       

      Regards,

      AKumar

    • Re: Export multiple objects to a single powerpoint slide
      Amit Kakkad

      Thanks Erich. Excellent example QVW.

       

      Regards,

       

      Amit

    • Re: Export multiple objects to a single powerpoint slide
      Amit Kakkad

      Thanks Erich. Excellent example QVW.

       

      Regards,

       

      Amit

    • Re: Export multiple objects to a single powerpoint slide
      Vijeta Sharma

      This macro exporting my chart objects as images into ppt

  • Re: Export multiple objects to a single powerpoint slide
    alec1982

    Thank you for the sample. One little issue is that all objects are coming on top of each other.. Can I assign positions? Also, Is there anyway I can include all these objects into a single image instead of multiple images?

     

    Best,

    Alec

    • Re: Export multiple objects to a single powerpoint slide
      LauraS056

      Hello alec,

       

      To choose the position of the objects, you can use :

       

      SET Shape = PPSlide.Shapes(PPSlide.Shapes.count)  ' Select the last picture which was pasted into the slide

       

        With Shape

        .LockAspectRatio = msoTRUE 'Allow size modification

        .PictureFormat.CropTop = 10 'crop

        .PictureFormat.CropBottom = 10

        '.PictureFormat.CropRight = 10

        .left=01

        .top= 77

        .height= 180

        .width=370

        END With

       

      I'm not sure you can export the objects in only one picture.