从 table 读取数据尤其无效 table
Reading data from a table does not work in particular table
我目前正在尝试通过从演示文稿中删除不需要的幻灯片来创建新的 PPT 演示文稿。在 Excel.
中的 table 的第一列中选择幻灯片 - 及其幻灯片编号 -
我试图通过使用另一个 table 而不是我想要使用的那个来解决这个问题并且它起作用了。由于某种原因,它似乎不适用于 "Table 3".
Sub CreatingNewPresentation()
Dim Destination1PPT As String
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim myTable As ListObject
Dim TempArray As Variant
Dim x As Long
If MsgBox("This can take a while", vbOKCancel + vbExclamation, "Creating new presentation") = vbCancel Then
Exit Sub
Else
Set ppApp = CreateObject("PowerPoint.Application")
Destination1PPT = "C:\Users\Steffen\Desktop\Test2.pptx"
Set ppPres = ppApp.Presentations.Open(Destination1PPT)
ppApp.Visible = True
ppApp.Activate
Set myTable = ActiveSheet.ListObjects("Table3")
TempArray = myTable.ListColumns(1).DataBodyRange
For x = ppApp.ActivePresentation.Slides.Count To 1 Step -1
If IsError(Application.Match(x, TempArray, False)) Then
ppApp.ActivePresentation.Slides(x).Delete
End If
Next
End If
End Sub
我希望代码能够打开演示文稿并删除除我存储在 "Table3" - 第 1 列中的幻灯片之外的所有幻灯片。
它所做的只是打开演示文稿,仅此而已。没有错误信息。
我发现了我犯的 "stupid" 错误。我正在获取所引用 table 的所有数据条目,而不是仅获取可见数据条目。
这有助于:
Set myTable = ThisWorkbook.Sheets("Sheet1").ListObjects("Table3")
TempArray = myTable.ListColumns(1).DataBodyRange.SpecialCells(xlCellTypeVisible)
我目前正在尝试通过从演示文稿中删除不需要的幻灯片来创建新的 PPT 演示文稿。在 Excel.
中的 table 的第一列中选择幻灯片 - 及其幻灯片编号 -我试图通过使用另一个 table 而不是我想要使用的那个来解决这个问题并且它起作用了。由于某种原因,它似乎不适用于 "Table 3".
Sub CreatingNewPresentation()
Dim Destination1PPT As String
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim myTable As ListObject
Dim TempArray As Variant
Dim x As Long
If MsgBox("This can take a while", vbOKCancel + vbExclamation, "Creating new presentation") = vbCancel Then
Exit Sub
Else
Set ppApp = CreateObject("PowerPoint.Application")
Destination1PPT = "C:\Users\Steffen\Desktop\Test2.pptx"
Set ppPres = ppApp.Presentations.Open(Destination1PPT)
ppApp.Visible = True
ppApp.Activate
Set myTable = ActiveSheet.ListObjects("Table3")
TempArray = myTable.ListColumns(1).DataBodyRange
For x = ppApp.ActivePresentation.Slides.Count To 1 Step -1
If IsError(Application.Match(x, TempArray, False)) Then
ppApp.ActivePresentation.Slides(x).Delete
End If
Next
End If
End Sub
我希望代码能够打开演示文稿并删除除我存储在 "Table3" - 第 1 列中的幻灯片之外的所有幻灯片。 它所做的只是打开演示文稿,仅此而已。没有错误信息。
我发现了我犯的 "stupid" 错误。我正在获取所引用 table 的所有数据条目,而不是仅获取可见数据条目。
这有助于:
Set myTable = ThisWorkbook.Sheets("Sheet1").ListObjects("Table3")
TempArray = myTable.ListColumns(1).DataBodyRange.SpecialCells(xlCellTypeVisible)