小编Roy*_*Roy的帖子

不占用 CPU 的 PowerPoint VBA 中的睡眠/等待计时器

我目前有一个 PowerPoint 演示文稿,它在计算机上用作某种信息亭或信息屏幕。它从磁盘上的文本文件中读取它的文本。此文本文件中的文本显示在 PowerPoint 的文本框中,并且每 5 秒刷新一次。通过这种方式,我们可以编辑 PowerPoint 中的文本,而无需编辑 PowerPoint 演示文稿本身,以便它继续运行。到目前为止效果很好,只有 PowerPoint VBA 不包含 Application.Wait 函数。在这里看到完整的子:

Sub Update_textBox_Inhoud()

Dim FileName As String
TextFileName = "C:\paht\to\textfile.txt"
If Dir$(FileName) <> "" Then

Application.Presentations(1).SlideShowSettings.Run
Application.WindowState = ppWindowMinimized


While True


    Dim strFilename As String: strFilename = TextFileName
    Dim strFileContent As String
    Dim iFile As Integer: iFile = FreeFile
    Open strFilename For Input As #iFile
    strFileContent = Input(LOF(iFile), iFile)
    Application.Presentations(1).Slides(1).Shapes.Range(Array("textBox_Inhoud")).TextFrame.TextRange = strFileContent
    Close #iFile


    waitTime = 5
    Start = Timer
    While Timer < Start + …
Run Code Online (Sandbox Code Playgroud)

powerpoint vba sleep wait

5
推荐指数
1
解决办法
5509
查看次数

标签 统计

powerpoint ×1

sleep ×1

vba ×1

wait ×1