我从excel中的项目列表自动创建pdf。一切正常,但有时由于程序关闭原始文件太快,创建的 pdf 文件已损坏。我意识到我可以增加时间,Application.Wait但如果列表很长,有时会增加很多时间。我正在尝试使用FileLen和循环读取文件大小,直到该值大于 0,然后关闭文件。我下面的代码抛出一个错误,说Next without For。
任何帮助表示赞赏。
For WaitTime = 0 To 0.5
If FileLen(SavePDFFldr & "\" & Description & ".pdf") > 10 Then
Application.SendKeys "^(q)", True
Application.SendKeys "{numlock}%s", True ' Closes the template when the file is done saving
Application.SendKeys "{Tab}", True
Application.SendKeys "{Enter}", True
Else: Next WaitTime
在此之前设置 SavePDFFldr 和 Description 的位置。