运行 循环时自动保存文件

Auto-Save File while running a loop

我有一长串本地网页要在 Excel 2013 中由宏解析。我想知道是否有任何方法可以在循环时每 5 分钟左右自动保存文件这些文件(>9000 个本地 .HTM 文件)。

这是一些代码:

Sub ImportFromWebPages()

'declare here some global variables

For startnumber = 1 to 9126

    'parse the .HTM files and extract the needed data
    'while running this loop (which will take some days to finish) 
    'Excel should save the file every 5 or 10 minutes.

Next startnumber
End Sub

对此有什么想法吗?

保存一定数量的文件后可能更容易保存,例如 5 个。请原谅我的伪代码:

Sub ImportFromWebPages()

    'declare here some global variables

    For startnumber = 1 to 9126

       'parse the .HTM files and extract the needed data
       'while running this loop (which will take some days to finish) 
       'Excel should save the file every 5 or 10 minutes.

        If startnumber Mod 5 = 0 Then

            ActiveWorkbook.Save

        End If

    Next startnumber
End Sub

有关 Mod and ActiveWorkbook.Save 的更多信息,请参阅以下链接。