如何从 PowerPoint 中的 Excel 个单元格访问数据(使用 VB 6.3)
How to access data from Excel cells in PowerPoint (using VB 6.3)
我想访问 Excel 中的数据以用于 powerpoint。我找到了这个教程 https://www.datanumen.com/blogs/2-effective-methods-to-extract-numbers-from-your-excel-cells/,但它描述了如何单独在 Excel 中使用它:
Sub ExtractNumbersFromCells()
Dim objRange As Range, nCellLength As Integer, nNumberPosition As Integer, strTargetNumber As String
' Initialization
strTargetNumber = ""
' Go through all the cells in the target range
For Each objRange In Range("B4:B14")
nCellLength = Len(objRange)
' Extract numbers from cells
For nNumberPosition = 1 To nCellLength
If IsNumeric(Mid(objRange, nNumberPosition, 1)) Then
strTargetNumber = strTargetNumber & Mid(objRange, nNumberPosition, 1)
End If
Next nNumberPosition
objRange.Offset(0, 1) = strTargetNumber
strTargetNumber = ""
Next objRange
End Sub
所以例如我在行上有我的值:B4:B14 ...
我想在 PowerPoint 中处理它们。怎么做?
这是一个从 PPT 自动化 Excel 的非常基本的示例:
'Requires VBA Project reference to "Microsoft Excel xx.0 Object Library"
Sub Tester()
Dim xlApp As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim x As Long
Set xlApp = New Excel.Application 'open Excel
xlApp.Visible = True 'make visible
Set wb = xlApp.Workbooks.Open("C:\Temp\Test.xlsx") 'open a workbook
Set ws = wb.Worksheets("Sheet1") 'get a worksheet reference
For x = 1 To 5 'loop over a range
Debug.Print ws.Cells(x, 1).Value 'read cell value
Next x
wb.Close False 'don't save changes
xlApp.Quit 'close excel
End Sub
大多数 VBA 示例都可以在线找到 Excel 中的自动化 PPT(因为使用 Excel 数据自动创建演示文稿是一个常见的用例)。
我想访问 Excel 中的数据以用于 powerpoint。我找到了这个教程 https://www.datanumen.com/blogs/2-effective-methods-to-extract-numbers-from-your-excel-cells/,但它描述了如何单独在 Excel 中使用它:
Sub ExtractNumbersFromCells()
Dim objRange As Range, nCellLength As Integer, nNumberPosition As Integer, strTargetNumber As String
' Initialization
strTargetNumber = ""
' Go through all the cells in the target range
For Each objRange In Range("B4:B14")
nCellLength = Len(objRange)
' Extract numbers from cells
For nNumberPosition = 1 To nCellLength
If IsNumeric(Mid(objRange, nNumberPosition, 1)) Then
strTargetNumber = strTargetNumber & Mid(objRange, nNumberPosition, 1)
End If
Next nNumberPosition
objRange.Offset(0, 1) = strTargetNumber
strTargetNumber = ""
Next objRange
End Sub
所以例如我在行上有我的值:B4:B14 ... 我想在 PowerPoint 中处理它们。怎么做?
这是一个从 PPT 自动化 Excel 的非常基本的示例:
'Requires VBA Project reference to "Microsoft Excel xx.0 Object Library"
Sub Tester()
Dim xlApp As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim x As Long
Set xlApp = New Excel.Application 'open Excel
xlApp.Visible = True 'make visible
Set wb = xlApp.Workbooks.Open("C:\Temp\Test.xlsx") 'open a workbook
Set ws = wb.Worksheets("Sheet1") 'get a worksheet reference
For x = 1 To 5 'loop over a range
Debug.Print ws.Cells(x, 1).Value 'read cell value
Next x
wb.Close False 'don't save changes
xlApp.Quit 'close excel
End Sub
大多数 VBA 示例都可以在线找到 Excel 中的自动化 PPT(因为使用 Excel 数据自动创建演示文稿是一个常见的用例)。