【问题标题】:PowerPoint VBA: open a text file and show each line on a seperate slidePowerPoint VBA:打开一个文本文件并在单独的幻灯片上显示每一行
【发布时间】:2011-03-13 01:56:25
【问题描述】:

我希望 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 语句的最佳方法是什么?

非常感谢您的帮助!

【问题讨论】:

  • 听起来更像是要求做这项工作而不是技术问题......阻碍你的点是什么?
  • iDevlop:你是对的。我已经相应地编辑了我的问题。

标签: vba powerpoint


【解决方案1】:

请理解我不能为你做所有的事情,但逻辑看起来是这样的:

MoreSlides = true
While moreSlides

        Open "mytextfile.txt" For Input As 1
        While Not EOF(1) and moreSlides
            Line Input #1, myline

            ' here comes the part inserting the line in the next slide
            ' You set moreSlides to false if you reach the end

         Wend
         close #1

Wend

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-14
    • 1970-01-01
    • 2019-07-07
    • 1970-01-01
    • 2023-03-29
    • 2022-12-23
    相关资源
    最近更新 更多