locked
Using the Cell Property of Table in PowerPoint VBA RRS feed

  • Question

  • Hello,

    I'm trying to insert a down arrow into a table's cell in a PPT slide with the following code, but I get an error 'object doesn't support this action'.  It highlights the line sh.table.cell(3,2).shape.autoshapetype = msoshapedownarrow.  Any idea why I'm getting this error?  Thanks!

    Sub tble()
        Dim sl As Slide, sh As Shape
           
        For Each sl In ActivePresentation.Slides
            If sl.SlideNumber = 93 Then
                For Each sh In sl.Shapes
                    If sh.Type = msoTable Then
                        sh.Table.Cell(3, 2).Shape.AutoShapeType = msoShapeDownArrow
                    End If
                Next sh
            End If
        Next
    End Sub

    Tuesday, September 11, 2012 9:26 PM

All replies

  • I think that you need to change the image in table, yes?
    But the image dont linked with table.
    Test this:

    Sub tble()
        Dim sl As Slide, sh As Shape
            
        For Each sl In ActivePresentation.Slides
            If sl.SlideNumber = 93 Then
                For Each sh In sl.Shapes 
                    If sh.Type = 1 Then        '''' Search by correct constant 
                        sh.AutoShapeType = msoShape24pointStar 
                    End If
                Next sh
            End If
        Next
    End Sub

    Nane

    Wednesday, September 12, 2012 8:27 PM
  • Actually, I'm trying to insert a symbol into a cell in a PowerPoint Table.  It is the equivelant of putting your cursor in the cell of a PowerPoint table and selecting the Insert tab/Symbol, and selecting the symbol to insert. 

    I have seen an example on this website of using the Shape object of Cell (i.e. sh.Table.Cell().Shape), and using the AutoShapeType.  However, I get "Object doesn't support this action" error.

    Is it possible to insert symbols with VBA?  I not, perhaps it is possible to insert a shape.

    Wednesday, September 12, 2012 8:36 PM
  • Try this:

    sh.Table.Cell(2, 3).Shape.TextFrame.TextRange.InsertSymbol FontName:="Symbol", CharNumber:=223

    Look at :

    http://msdn.microsoft.com/en-us/library/office/aa172287(v=office.11).aspx


    Nane

    Thursday, September 13, 2012 12:24 PM
  • Yes, this at first glance appears to be what I need.  However, it seems to only work for certain symbols and not for others.  I was able to insert a register sign, for example, but not the symbols that I need (Up-pointing Triangle and Down-Pointing Triangle).  I'm not sure why, but perhaps VBA doesn't recognize these symbols. 

    Alternatively, I was able to insert a a left-pointing arrow using sh.table.Cell(3,4).Shape.TextFram.TextRange.Text = Chr(17), but when I try this with Chr(31), which is an Down-Pointing Triangle, I get a blank cell.  I'm puzzled.

    Thursday, September 13, 2012 4:18 PM
  • I think you can to insert any symbol but you just need to select especific font. The number you can to see in Insert-Symbol

    Nane

    Thursday, September 13, 2012 5:29 PM
  • I found the font for the Up/Down Triangles - Wingdings 3.  I think you are right that I must include the correct font.  Now I have another problem.  When I click on the Triangle in the Insert/Symbols, the ASCII is not avaible.  Rather it changes to "Symbol (decimal)" and "Symbol (hex)".  I wonder if it is possible to use "Symbol" character codes rather than ASCII or Unicode.
    Thursday, September 13, 2012 6:13 PM
  • Do you try this:

    sh.Table.Cell(2, 3).Shape.TextFrame.TextRange.InsertSymbol    FontName:="Wingdings 3", CharNumber:=130

    I think that I dont understand, send your sample again, please


    Nane


    • Edited by nanebnu Thursday, September 13, 2012 6:21 PM
    Thursday, September 13, 2012 6:15 PM
  • 112 is the "Symbol (dec)" code for up-pointing triangle, but the InsertSymbol method wants ASCII or Unicode.  THanks!

    Sub InsertShapeInCell()
        Dim sl As Slide
        Dim sh As Shape
        Dim newarw As Shape

        For Each sl In ActivePresentation.Slides
            If sl.SlideNumber = 94 Then
                For Each sh In sl.Shapes
                    If sh.Type = msoTable Then
                        sh.Table.Cell(3, 2).Shape.TextFrame.TextRange.InsertSymbol FontName:="Wingdings 3", CharNumber:=112
                    End If
                Next
            End If
        Next
    End Sub

       
    Thursday, September 13, 2012 6:23 PM