Announcement

Collapse
No announcement yet.

Excel to PowerPoint. Creating PPT slides per Page Break from Excel.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Excel to PowerPoint. Creating PPT slides per Page Break from Excel.



    Dear All,

    Trust you are all well.

    I am using the following code to create a slide into powerpoint:

    Code:
     
     Private Sub CommandButton3_Click() 'Export to PowerPoint          Dim PowerPointApp As Object     Dim PPApp As PowerPoint.Application     Dim PPPres As PowerPoint.Presentation     Dim PPSlide As PowerPoint.Slide     Dim n As Long     Dim rng As Range     Dim ws As Worksheet     Dim myShape As Object          Set ws = Sheets(Me.CoBxSheet.Value)          ws.Activate          n = Range("A" & Rows.Count).End(xlUp).Row      ' Reference instance of PowerPoint     On Error Resume Next     ' Check whether PowerPoint is running     Set PPApp = GetObject(, "PowerPoint.Application")     If PPApp Is Nothing Then         ' PowerPoint is not running, create new instance         Set PPApp = CreateObject("PowerPoint.Application")         ' For automation to work, PowerPoint must be visible         PPApp.Visible = True     End If     On Error GoTo 0      ' Reference presentation and slide     On Error Resume Next     If PPApp.Windows.Count > 0 Then         ' There is at least one presentation         ' Use existing presentation         Set PPPres = PPApp.ActivePresentation         ' Use active slide         Set PPSlide = PPPres.Slides.Add(PPPres.Slides.Count + 1, 12)             '(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)     Else         ' There are no presentations         ' Create new presentation         Set PPPres = PPApp.Presentations.Add         ' Add first slide         Set PPSlide = PPPres.Slides.Add(1, ppLayoutBlank)     End If     On Error GoTo 0      ' Some PowerPoint actions work best in normal slide view     PPApp.ActiveWindow.ViewType = ppViewNormal      Set rng = ws.Range("A1:G" & n)          ws.Shapes("EP_Tools").Visible = False              rng.Copy          PPSlide.Shapes.PasteSpecial DataType:=2     Set myShape = PPSlide.Shapes(PPSlide.Shapes.Count)            'myShape.Left = 66       'myShape.Top = 152      PPApp.Visible = True     PPApp.Activate          Application.CutCopyMode = False          ws.Shapes("EP_Tools").Visible = True       Sheets(2).Activate      ' Clean up     Set PPSlide = Nothing     Set PPPres = Nothing     Set PPApp = Nothing  End Sub
    The above code works as desire but if the sheet contents is more than one page, when pasting to powerpoint is not readable as it gets too small. What I need is to create additional slides per excel page break. Any assistance on this matter will be highly appreciated. Best regards, Filipe

  • #2


    I have found a solution for my case hence, setting this thread as SOLVED.

    Basically, I have created a userform with 8 TextBoxes. Each TextBox is for a PPT slide and the value to enter is the Rows numbers users want to be visible on that specific slide (e.g. "1:40").

    As soon the user finish setting the number of slides and the range, there is a CommandButton that creates the slides.

    Best regards,
    Filipe

    Comment

    Working...
    X