none
Merging cells with Excel to PowerPoint using VBA RRS feed

  • Question

  • Hi,

    I have a table in PowerPoint which I build in Excel using AddTable. When the file is running, the table will be made in PowerPoint with some information in it. 

    Now I want to merge 2 cells using VBA. Is there a way to do this?

    I hope someone can help

    Thanks!

    Tuesday, October 18, 2016 11:43 AM

Answers

  • Hi,

    Have you resolved the issue?

    If not, how do you use the code to merge?

    I could successfully merge cells by using Cell.Merge Method (PowerPoint).

    Please see the .gif below.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ganeshgebhard Tuesday, October 25, 2016 2:36 PM
    Tuesday, October 25, 2016 10:58 AM
    Moderator

All replies

  • Can you share that part of code where you are using AddTable

    Best Regards,
    Asadulla Javed,
    Jadavpore & Asansol


    Tuesday, October 18, 2016 2:46 PM
    Answerer
  • Of Course!

    'Table
            Set Table = SlidePP.Shapes.AddTable(7, 4)
            With Table
                'General
                .Table.ApplyStyle "{5940675A-B579-460E-94D1-54222C63F5DA}", True
                .Left = 25
                .Height = 20
                .Top = 150
                .Fill.ForeColor.RGB = RGB(255, 255, 255)
                
                'Column 1: GOR
                .Table.Cell(1, 1).Shape.TextFrame.TextRange.Text = "GOR"
                .Table.Cell(1, 1).Shape.TextFrame.TextRange.Font.Name = "Verdana Body"
                .Table.Cell(1, 1).Shape.TextFrame.TextRange.Font.Size = 18
                .Table.Cell(1, 1).Shape.TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 125)
                .Table.Columns(1).Width = 70
                    'Layout
                .Table.Columns(1).Cells.Borders(ppBorderTop).ForeColor.RGB = RGB(0, 155, 225)
                .Table.Columns(1).Cells.Borders(ppBorderLeft).ForeColor.RGB = RGB(0, 155, 225)
                .Table.Columns(1).Cells.Borders(ppBorderRight).ForeColor.RGB = RGB(0, 155, 225)
                .Table.Columns(1).Cells.Borders(ppBorderBottom).ForeColor.RGB = RGB(0, 155, 225)
                    'Font Size
                .Table.Cell(2, 1).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(3, 1).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(4, 1).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(5, 1).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(6, 1).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(7, 1).Shape.TextFrame.TextRange.Font.Size = 9
                
                'Column 2: Title
                .Table.Columns(2).Cells.Borders(ppBorderTop).ForeColor.RGB = RGB(0, 155, 225)
                .Table.Columns(2).Cells.Borders(ppBorderRight).ForeColor.RGB = RGB(0, 155, 225)
                .Table.Columns(2).Cells.Borders(ppBorderBottom).ForeColor.RGB = RGB(0, 155, 225)
                    'Layout
                .Table.Cell(1, 2).Shape.TextFrame.TextRange.Text = "Title"
                .Table.Cell(1, 2).Shape.TextFrame.TextRange.Font.Name = "Verdana Body"
                .Table.Cell(1, 2).Shape.TextFrame.TextRange.Font.Size = 18
                .Table.Cell(1, 2).Shape.TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 125)
                .Table.Columns(2).Width = 250
                    'Font Size
                .Table.Cell(2, 2).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(3, 2).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(4, 2).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(5, 2).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(6, 2).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(7, 2).Shape.TextFrame.TextRange.Font.Size = 9
                
                'Column 3: Occurrence Date
                .Table.Columns(3).Cells.Borders(ppBorderTop).ForeColor.RGB = RGB(0, 155, 225)
                .Table.Columns(3).Cells.Borders(ppBorderRight).ForeColor.RGB = RGB(0, 155, 225)
                .Table.Columns(3).Cells.Borders(ppBorderBottom).ForeColor.RGB = RGB(0, 155, 225)
                    'Layout
                .Table.Cell(1, 3).Shape.TextFrame.TextRange.Text = "Occurrence Date"
                .Table.Cell(1, 3).Shape.TextFrame.TextRange.Font.Name = "Verdana Body"
                .Table.Cell(1, 3).Shape.TextFrame.TextRange.Font.Size = 18
                .Table.Cell(1, 3).Shape.TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 125)
                .Table.Columns(3).Width = 280
                    'Font Size
                .Table.Cell(2, 3).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(3, 3).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(4, 3).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(5, 3).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(6, 3).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(7, 3).Shape.TextFrame.TextRange.Font.Size = 9
                
                'Column 4: Risk
                .Table.Columns(4).Cells.Borders(ppBorderTop).ForeColor.RGB = RGB(0, 155, 225)
                .Table.Columns(4).Cells.Borders(ppBorderRight).ForeColor.RGB = RGB(0, 155, 225)
                .Table.Columns(4).Cells.Borders(ppBorderBottom).ForeColor.RGB = RGB(0, 155, 225)
                    'Layout
                .Table.Cell(1, 4).Shape.TextFrame.TextRange.Text = "Risk"
                .Table.Cell(1, 4).Shape.TextFrame.TextRange.Font.Name = "Verdana Body"
                .Table.Cell(1, 4).Shape.TextFrame.TextRange.Font.Size = 18
                .Table.Cell(1, 4).Shape.TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 125)
                .Table.Columns(4).Width = 80
                    'Font Size
                .Table.Cell(2, 4).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(3, 4).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(4, 4).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(5, 4).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(6, 4).Shape.TextFrame.TextRange.Font.Size = 9
                .Table.Cell(7, 4).Shape.TextFrame.TextRange.Font.Size = 9
            End With


    Tuesday, October 18, 2016 3:06 PM
  • Have you tried Merge method. A sample code...

    For Merge use 1st cell as starting point and use merge method. Use last cell till you want merging in Mergeto Argument.

    Below code merges from Cell(2,1) to Cell(3,3). You have to ensure the cells create a rectangle shape.

    Sub Meerge()
    
    Dim tbl As Table
    
    Set tbl = ActivePresentation.Slides(1).Shapes(3).Table
    
    With tbl
        .Cell(2, 1).Merge mergeto:=.Cell(3, 3)
    End With
    
    
    End Sub
    



    Best Regards,
    Asadulla Javed,
    Jadavpore & Asansol

    Tuesday, October 18, 2016 4:44 PM
    Answerer
  • It does not work..
    Wednesday, October 19, 2016 8:11 AM
  • Hi,

    Have you resolved the issue?

    If not, how do you use the code to merge?

    I could successfully merge cells by using Cell.Merge Method (PowerPoint).

    Please see the .gif below.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ganeshgebhard Tuesday, October 25, 2016 2:36 PM
    Tuesday, October 25, 2016 10:58 AM
    Moderator