Alert if empty cell found in power point tables and in which slide using vba

血红的双手。 提交于 2020-07-22 05:59:06

问题


I have to find and alert that if empty cell found in each tables in power point.

I have found the below code here, but it does not work and it should not be find for all table, not for selected one.

    Sub CheckTableCells()

    Dim oCell As Cell
    Dim oRow As Row
    Dim MyRange As Range

    For Each oRow In Selection.Tables(1).Rows
        For Each oCell In oRow.Cells
            If Selection.Text = Chr(13) & Chr(7) Then
                oCell.Select
                MsgBox oCell.RowIndex & " " & oCell.ColumnIndex & " is empty."
            End If
        Next oCell
    Next oRow

    End Sub

Please anyone help me for this.


回答1:


This code loops through each slide in the active presentation, and in each slide, check whether the each shape on the slide contains a table, and if it does, checks whether each cell is blank. Cheers.

Sub CheckTableCells()

    Dim vSlide As Slide
    Dim vShape As Shape
    Dim vRow As Long
    Dim vColumn As Long

    For Each vSlide In Application.ActivePresentation.Slides
        For Each vShape In vSlide.Shapes
            If vShape.HasTable Then
                For vRow = 1 To vShape.Table.Rows.Count
                    For vColumn = 1 To vShape.Table.Columns.Count
                        If vShape.Table.Cell(vRow, vColumn).Shape.TextFrame.TextRange.Text = "" Then
                            MsgBox vSlide.Name & " Table: """ & vShape.Name & """ cell (" & vRow & "," & vColumn & ") is blank."
                        End If
                    Next
                Next
            End If
        Next
    Next

End Sub



来源:https://stackoverflow.com/questions/56974889/alert-if-empty-cell-found-in-power-point-tables-and-in-which-slide-using-vba

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!