我需要获取表格的选定单元格。
我尝试了以下代码
Set oTbl = .ShapeRange(1).Table
For x = 1 To oTbl.Rows.Count
For y = 1 To oTbl.Columns.Count
If oTbl.Cell(x, y).Selected Then
With oTbl.Cell(x, y).Shape
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Fill.Visible = True
End With
End If
Next
Next
如果您使用的是 vba,这可以正常工作,但是我使用 vb.net 创建了一个 vsto 并使用以下代码为完整的表格着色
Dim oShape As PowerPoint.Shape = Nothing
Dim oTable As PowerPoint.Table
With Globals.ThisAddIn.Application.ActiveWindow.Selection
For Each oShape In .ShapeRange
oShape.Select()
Exit For
Next
oTable = oShape.Table
Dim i As Integer = 0
Dim j As Integer = 0
For i = 1 To oTable.Rows.Count
For j = 1 To oTable.Columns.Count
If oTable.Cell(i, j).Selected = True Then
With oTable.Cell(i, j).Shape
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoTrue
End With
End If
Next
Next
End With
请帮忙
谢谢
乐华M