none
Using the next bullets in PowerPoint using Excel vba RRS feed

  • Question

  • Hi,

    I have a PowerPoint template which I start and fill using Excel vba.

    The first page is 'Contents' and is uses bullets to sum everything up. In Excel vba, I programmed it so that all the bullets used properly. The result:

    Now I want this:

    The Code:

    Sub CompletePowerPointFileTESTING() 'First we declare the variables we will be using Dim newPowerPoint As PowerPoint.Application Dim activeSlide As PowerPoint.Slide Dim cht As Excel.ChartObject 'Define worksheets Set WB = ThisWorkbook Set WSNumOfOpp = WB.Worksheets(6) Set WSIndex = WB.Worksheets(1) 'Look for existing instance On Error Resume Next Set newPowerPoint = GetObject(, "PowerPoint.Application") On Error GoTo 0 'Let's create a new PowerPoint If newPowerPoint Is Nothing Then Set newPowerPoint = New PowerPoint.Application End If 'Make a presentation in PowerPoint If newPowerPoint.Presentations.Count = 0 Then newPowerPoint.Presentations.Open ("X:\blank.potm") End If 'Show the PowerPoint newPowerPoint.Visible = True 'All shapes and texts slide 1 Set SlideOne = newPowerPoint.ActivePresentation.Slides(1) SlideOne.Shapes(1).TextFrame.TextRange.Text = "Title" SlideOne.Shapes(2).TextFrame.TextRange.Text = "Sub-Tile" SlideOne.Shapes(3).TextFrame.TextRange.Text = "Text 1" SlideOne.Shapes(4).TextFrame.TextRange.Text = "Text 2" SlideOne.Shapes(5).TextFrame.TextRange.Text = "Text 3" SlideOne.Shapes(6).TextFrame.TextRange.Text = "Location" 'All shapes and texts slide 2 Set SlideTwo = newPowerPoint.ActivePresentation.Slides(2) SlideTwo.Shapes(4).TextFrame.TextRange.Text = "Contents" 'slide 2 contents ContOne = "Test 1" ContTwo = "Test 2" ContThree = "Test 3" ContFour = "Test 4" ContFive = "Test 5" ContSix = "Test 6" ContSeven = "Test 7"

    CheckOne = "Check 1"

    SlideTwo.Shapes(5).TextFrame.TextRange.Text = ContOne & Chr(10) & ContTwo & Chr(10) & ContThree & Chr(10) & ContFour & Chr(10) & ATAOne & Chr(10) & ContFive & Chr(10) & ContSix & Chr(10) & ContSeven End Sub


    Does anyone know how to do this?

    Thanks!



    Thursday, November 3, 2016 12:13 PM

Answers

  • Hi i have moodified your code a little but to set the different levels in bullet points (refer at the end of the code)

    Especially you had to change the Chr(10) to vbNewLine

    and then for each line of the text you can set the IndentLevel there

    Sub CompletePowerPointFileTESTING()
    
        'First we declare the variables we will be using
        
            Dim newPowerPoint As PowerPoint.Application
            Dim activeSlide As PowerPoint.Slide
            Dim cht As Excel.ChartObject
            
         'Define worksheets
         Set WB = ThisWorkbook
         'Set WSNumOfOpp = WB.Worksheets(6)
         'Set WSIndex = WB.Worksheets(1)
         
         'Look for existing instance
            'On Error Resume Next
            Set newPowerPoint = GetObject(, "PowerPoint.Application")
            'On Error GoTo 0
         
        'Let's create a new PowerPoint
            If newPowerPoint Is Nothing Then
                Set newPowerPoint = New PowerPoint.Application
            End If
        'Make a presentation in PowerPoint
            If newPowerPoint.Presentations.Count = 0 Then
            '    newPowerPoint.Presentations.Open ("X:\blank.potm")
            End If
         
        'Show the PowerPoint
            newPowerPoint.Visible = True
            newPowerPoint.Presentations.Add
        
        'All shapes and texts slide 1
        Set SlideOne = newPowerPoint.ActivePresentation.Slides(1)
                
                SlideOne.Shapes(1).TextFrame.TextRange.Text = "Title"
                SlideOne.Shapes(2).TextFrame.TextRange.Text = "Sub-Tile"
                'SlideOne.Shapes(3).TextFrame.TextRange.Text = "Text 1"
                'SlideOne.Shapes(4).TextFrame.TextRange.Text = "Text 2"
                'SlideOne.Shapes(5).TextFrame.TextRange.Text = "Text 3"
                'SlideOne.Shapes(6).TextFrame.TextRange.Text = "Location"
        
        'All shapes and texts slide 2
       
        Set SlideTwo = newPowerPoint.ActivePresentation.Slides(2)
                SlideTwo.Shapes(4).TextFrame.TextRange.Text = "Contents"
                
                'slide 2 contents
                ContOne = "Test 1"
                ContTwo = "Test 2"
                ContThree = "Test 3"
                ContFour = "Test 4"
                ContFive = "Test 5"
                ContSix = "Test 6"
                ContSeven = "Test 7"
                     CheckOne = "Check 1"
                Set shp = SlideTwo.Shapes(2)
                Set tr = shp.TextFrame.TextRange
                tr.Text = ContOne & vbNewLine & ContTwo & vbNewLine & ContThree & vbNewLine & ContFour & vbNewLine & ContFive & vbNewLine & ContSix & vbNewLine & ContSeven & vbNewLine & CheckOne
                
                'Set the levels wherever you want it to keep it
                tr.Lines(0).IndentLevel = 1
                tr.Lines(1).IndentLevel = 2
                tr.Lines(2).IndentLevel = 1
                tr.Lines(3).IndentLevel = 2
                tr.Lines(4).IndentLevel = 2
                tr.Lines(5).IndentLevel = 3
                tr.Lines(6).IndentLevel = 4
                tr.Lines(7).IndentLevel = 5
                tr.Lines(8).IndentLevel = 5
                
    End Sub


    Vish Mishra

    • Marked as answer by ganeshgebhard Thursday, November 3, 2016 3:44 PM
    Thursday, November 3, 2016 3:24 PM