将表格从 powerpoint 文件导出到 excel 文件
Export tables from a powerpoint file to an excel file
我有一个包含很多表格的 powerpoint 文件。这些表具有相同的列。如何将这些表格自动导出到一个 excel 文件?
Sub DataTransfer()
Dim shp As Shape, i%, j%
' Dim colCount As Integer
' Dim rowCount As Integer
Dim rowNum As Integer
Dim rng As Object
Set rng = GetObject(, "Excel.Application").Range("a1") ' start at top of worksheet
For i = 1 To ActivePresentation.Slides.Count
For Each shp In ActivePresentation.Slides(i).Shapes
If shp.HasTable Then
With shp.Table
colCount = .Columns.Count
rowCount = .Rows.Count
For rowNum = 0 To .Rows.Count - 1
For j = 0 To 4
rng.Offset(rowNum, j).Value = (.Cell(rowNum + 1, j + 1).Shape.TextFrame.TextRange)
Next j
rng.Offset(rowNum, 4).Interior.Color = (.Cell(rowNum + 1, 5).Shape.TextFrame.TextRange)
Next rowNum
Set rng = rng.Offset(rowNum + 1)
End With
End If
Next shp
Next i
我有一个包含很多表格的 powerpoint 文件。这些表具有相同的列。如何将这些表格自动导出到一个 excel 文件?
Sub DataTransfer()
Dim shp As Shape, i%, j%
' Dim colCount As Integer
' Dim rowCount As Integer
Dim rowNum As Integer
Dim rng As Object
Set rng = GetObject(, "Excel.Application").Range("a1") ' start at top of worksheet
For i = 1 To ActivePresentation.Slides.Count
For Each shp In ActivePresentation.Slides(i).Shapes
If shp.HasTable Then
With shp.Table
colCount = .Columns.Count
rowCount = .Rows.Count
For rowNum = 0 To .Rows.Count - 1
For j = 0 To 4
rng.Offset(rowNum, j).Value = (.Cell(rowNum + 1, j + 1).Shape.TextFrame.TextRange)
Next j
rng.Offset(rowNum, 4).Interior.Color = (.Cell(rowNum + 1, 5).Shape.TextFrame.TextRange)
Next rowNum
Set rng = rng.Offset(rowNum + 1)
End With
End If
Next shp
Next i