Consulting

Results 1 to 5 of 5

Thread: [ask] Change text format in imported excel table to all slides in PPT 2010

  1. #1

    [ask] Change text format in imported excel table to all slides in PPT 2010

    Hello All,

    Newbie here. This is my first post.

    I have problem about how to create Vba for my Powerpoint file.
    here's the situation:

    i Copy pasted excel table containing text to powerpoint.

    what i want to have is:
    - change all text size to 9
    - change all align to left

    that will apply to any tables on any slides on whole powerpoint file.
    i can't do this manualy one by one, as there will be many slides.
    attached the file example.
    try to write the code, but i am new to vba, not sure what to write.

    how to complete the code below?

    sub changetext ()
    For Each sld In ActivePresentation.Slides
    For Each sh In sld.Shapes

    .TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignLeft
    .TextFrame.TextRange.Font.Size = 9

    Next
    Next
    end sub

    is anyone can solve my problem?

    thanks before.
    Attached Files Attached Files

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    See it this works

    Sub FixXL()
    Dim oshp As Shape
    Dim osld As Slide
    Dim otbl As Table
    Dim iRow As Integer
    Dim iCol As Integer
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    If oshp.HasTable Then
    Set otbl = oshp.Table
    For iRow = 1 To otbl.Rows.Count
    For iCol = 1 To otbl.Columns.Count
    otbl.Cell(iRow, iCol).Shape.TextFrame.TextRange.Font.Size = 9
    Next iCol
    Next iRow
    End If
    Next oshp
    Next osld
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    That's amazingly works!
    You're trully Master!
    many thanks. you saved my day

    anyway, is it different code if want to apply to text box / shapes?

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    As written it apply only to tables (which pasted tables from XL will be)

    To change tables, shapes, and textboxes but not placeholders

    Dim oshp As Shape
    Dim osld As Slide
    Dim otbl As Table
    Dim iRow As Integer
    Dim iCol As Integer
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    'Is it a table
    If oshp.HasTable Then 'YES
    Set otbl = oshp.Table
    For iRow = 1 To otbl.Rows.Count
    For iCol = 1 To otbl.Columns.Count
    otbl.Cell(iRow, iCol).Shape.TextFrame.TextRange.Font.Size = 9
    Next iCol
    Next iRow
    Else 'NO
    'Don't change placeholders
    If Not oshp.Type = msoPlaceholder Then
    If oshp.HasTextFrame Then
    oshp.TextFrame.TextRange.Font.Size = 9
    End If
    End If
    End If
    Next oshp
    Next osld
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    Ok i got it

    above code works well.

    Once again thanks for your help.

    i guess case SOLVED.

    is there no thanks button in this thread reply?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •