PowerPoint VBA:打开文本文件并在单独的幻灯片上显示每一行
我希望 PowerPoint 打开一个外部文本文件,并在演示文稿的幻灯片 1 上显示该文件的第 1 行,在幻灯片 2 上显示第 2 行,等等。
如果幻灯片的数量大于文本文件中的行数,我会喜欢再次从第 1 行开始。
这是我到目前为止所拥有的(混合代码和伪代码):
Dim FileName, FSO, MyFile
FileName = "C:\test.txt"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MyFile = FSO.OpenTextFile(FileName, 1)
For i = 1 To ActivePresentation.Slides.Count
If LINE(i) EXISTS IN TEXT FILE THEN
ActivePresentation.Slides(i).Shapes("myshape").TextFrame.TextRange.Text = LINE(i)
ELSE START AT LINE(1) AGAIN
End If
Next
MyFile.Close
如何使用 i
引用文本文件中的行,以及执行 if/then 语句的最佳方法是什么?
我们将非常感谢您的帮助!
I want PowerPoint to open an external text file and show line 1 of this file on slide 1 of my presentation, line 2 on slide 2, etc.
If the number of slides is larger than the number of lines in the text file, I would like to start at line 1 again.
Here's what I have so far (mixed code and pseudocode):
Dim FileName, FSO, MyFile
FileName = "C:\test.txt"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MyFile = FSO.OpenTextFile(FileName, 1)
For i = 1 To ActivePresentation.Slides.Count
If LINE(i) EXISTS IN TEXT FILE THEN
ActivePresentation.Slides(i).Shapes("myshape").TextFrame.TextRange.Text = LINE(i)
ELSE START AT LINE(1) AGAIN
End If
Next
MyFile.Close
How do I refer to the lines in the text file using i
, and what would be the best way to do the if/then-statement?
Your help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请理解我无法为您完成所有事情,但逻辑看起来是这样的:
Please understand I cannot do the whole thing for you but the logic somehow looks like this: