我如何解决这个Excel Visual Basic运行时错误'62'?
我在Excel中创build了一个Visual Basic脚本来打开,抓取内容并closures一个(超过一百个)Word文档。
部分代码是:
Private Function GrabTextFile(ByVal file_name As String) As String Dim fnum As Long fnum = FreeFile() Open file_name For Input As #fnum GrabTextFile = Input$(LOF(fnum), #fnum) Close #fnum End Function
(其余的代码很大程度上基于VB帮助器的这个页面 。)
该脚本在线失败:
GrabTextFile = Input$(LOF(fnum), #fnum)
与消息:
Run-time error '62': Input past end of file
它在文档34上失败。但是,如果我删除了特定的文档 ,然后重新运行该脚本,则在该位置的新文档上失败。 这意味着我有一个问题,释放一些内存(?)。
由于这些是Word文档,所以我build议你尝试使用GrabWordFile
函数,而不是在VB Helper页面上列出的GrabTextFile
函数。