【发布时间】:2020-11-29 15:48:58
【问题描述】:
我正在尝试读取每两行文本,创建一张幻灯片,然后使用 VBA 代码将每一行分别插入 2 x 1 表格的单元格中。
Public Sub newSlide()
Dim FileNum As Integer
Dim DataLine As String
Dim Count As Integer
Count = 0
FileNum = FreeFile()
Open "C:\Users\ADMININST\Documents\my.txt" For Input As #FileNum
While Not EOF(FileNum)
Count = Count + 1
Line Input #FileNum, DataLine ' read in data 1 line at a time
' decide what to do with dataline,
' depending on what processing you need to do for each case
Debug.Print ("Love you")
If Count Mod 2 = 1 Then
Dim pptSlide As Slide
Dim pptLayout As CustomLayout
Set pptLayout = ActivePresentation.Slides(1).CustomLayout
Set pptSlide = ActivePresentation.Slides.AddSlide(2, pptLayout)
'ActivePresentation.Slides.Add Index:=ActivePresentation.Slides.Count + 1, Layout:=ppLayoutCustom
Dim pptTable As Table
pptTable = pptSlide.Shapes.AddTable(2, 1).Select
pptTable.Cell(1, Count Mod 2) = DataLine
End If
Wend
End Sub
我得到一个编译错误;
下面一行的“预期函数或变量”。似乎 Select 没有返回表格。
pptTable = pptSlide.Shapes.AddTable(2, 1).Select
【问题讨论】:
标签: vba powerpoint