6 Replies Latest reply: Feb 24, 2016 9:44 PM by sachin godhania RSS

    Export straight/PIVOT to PPT problem

    sachin godhania

      Hi All ,

       

      I am facing some prob in pasting straight/pivot to ppt to a specific slideno, I  am using code as below ,

       

      sub ppt

      set objPPT = CreateObject("PowerPoint.Application")

      objPPT.Visible = True

      Set objPresentation = objPPT.Presentations.Add

      ActiveDocument.Sheets("SH01").Activate

      Set obj = ActiveDocument.GetSheetObject("CH03")

      Set PPSlide = objPresentation.Slides.Add(1,obj.GetObjectType) 

      obj.CopyTableToClipboard true

      With PPSlide

      objPPT.CommandBars.ExecuteMso ("PasteSourceFormatting")

      End With

      Set obj = ActiveDocument.GetSheetObject("CH04")

      Set PPSlide = objPresentation.Slides.Add(2,obj.GetObjectType) 

      obj.CopyTableToClipboard true

      With PPSlide

      objPPT.CommandBars.ExecuteMso ("PasteSourceFormatting")

      End With

        End Sub

       

      By this code table always copies on first slide of the PPT and doesn't respect the .left and top Position.

       

      Please let me know if any body had encountered the same issue. Thanks !

       

      Regards,

      Sachin

          • Re: Export straight/PIVOT to PPT problem
            sachin godhania

            Hi Suri,

             

            I have gone through this link. The issue is I am using copytabletoclipboard and its pasting on slide1 only.

             

            Regards,

            Sachin

              • Re: Export straight/PIVOT to PPT problem
                Hirish V

                Hi,

                 

                Check with this code,

                Are you exporting two objects or what's the issue can you elaborate!!

                Sub ExportPPT  
                Set objPPT = CreateObject("PowerPoint.Application")  
                objPPT.Visible = True  
                Set objPresentation = objPPT.Presentations.open("YourPath\ppt.pptx")'file Path
                Set PPSlide = objPresentation.Slides.Add(1,12)  
                ActiveDocument.GetSheetObject("CH02").CopyBitmapToClipboard  
                PPSlide.Shapes.Paste  
                PPSlide.Shapes(PPSlide.Shapes.Count).Top = 150 'This sets the top location of the image  
                PPSlide.Shapes(PPSlide.Shapes.Count).Left = 15 'This sets the left location  
                PPSlide.Shapes(PPSlide.Shapes.Count).Width = 240  
                PPSlide.Shapes(PPSlide.Shapes.Count).Height = 250  
                  
                  
                Set PPSlide = objPresentation.Slides.Add(1,12)  
                ActiveDocument.GetSheetObject("CH02").CopyBitmapToClipboard  
                PPSlide.Shapes.Paste  
                PPSlide.Shapes(PPSlide.Shapes.Count).Top = 150 'This sets the top location of the image  
                PPSlide.Shapes(PPSlide.Shapes.Count).Left = 15 'This sets the left location  
                PPSlide.Shapes(PPSlide.Shapes.Count).Width = 100  
                PPSlide.Shapes(PPSlide.Shapes.Count).Height = 200  
                  
                Set PPSlide = Nothing  
                Set PPPres = Nothing  
                Set PPApp = Nothing  
                End Sub  
                

                 

                HTH,

                Hirish

                  • Re: Export straight/PIVOT to PPT problem
                    sachin godhania

                    HI Hirish,

                     

                    Thanks for code.

                    I need to user obj.CopyTableToClipboard instead of CopyBitmapToClipboard    in order to copy table.

                     

                    Regards,

                    Sachin

                      • Re: Export straight/PIVOT to PPT problem
                        Jeremiah Kurpat

                        Hi Sachin!

                         

                        You should try this code:

                         

                        sub ppt

                         

                        set objPPT = CreateObject("PowerPoint.Application")

                        objPPT.Visible = True

                        Set objPresentation = objPPT.Presentations.Add

                         

                        For j=1 To 2

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

                        next

                         

                        ActiveDocument.Sheets("SH01").Activate

                         

                        Set obj = ActiveDocument.GetSheetObject("CH03")

                        objPresentation.Slides(1).Select

                        obj.CopyTableToClipboard true

                        objPPT.CommandBars.ExecuteMso ("PasteSourceFormatting")

                         

                        Set obj = ActiveDocument.GetSheetObject("CH04")

                        objPresentation.Slides(2).Select

                        obj.CopyTableToClipboard true

                        objPPT.CommandBars.ExecuteMso ("PasteSourceFormatting")

                         

                        End sub

                         

                        I found out you don't need the With PPSlide to do Paste Source Formatting since it will paste it in you active slide. So you want to choose the slide you want to paste it on with the statement:

                         

                        objPresentation.Slides(1).Select


                        Hope this helps!!