簡體   English   中英

PowerPoint VBA:打開文本文件並在單獨的幻燈片上顯示每一行

[英]PowerPoint VBA: open a text file and show each line on a seperate slide

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

您的幫助將不勝感激!

請理解,我無法為您做全部事情,但是邏輯看起來像這樣:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM