处理多个文档时出现 Word 错误
现在我们有一个程序可以打开文件夹中的所有单词文件并向页脚添加一些信息。从 Windows XP 和 Word 2003 切换到 Windows 7 和 Word 2007 后,我们开始出现以下错误:
运行时错误 '5096':
EOALPHABETICARABICARABICABJADARABICALPHABAHTTEXTCAPSCA
(c:\Users...\Content.MSO\8BE508C6.docx)
它发生随机在任何文件中(可以是 10 个文件或 100 个文件)。我认为网络驱动器上的文件可能有问题,因此我修改了程序,首先在本地复制每个文件,将页脚添加到该副本,然后将其复制回网络。然而,这似乎不起作用。我正在寻找有关如何解决问题或可能重写解决方案的任何建议。但是,我需要将解决方案保留在 VBA 中,因为该应用程序是一个更大套件的一部分,该套件尚未准备好进行 .NET 重写。
Right now we have a program that opens all of the word files in a folder and adds some information to the footer. After switching from Windows XP and Word 2003 to Windows 7 and Word 2007 we have started getting the following error:
Run-time error '5096':
EOALPHABETICARABICARABICABJADARABICALPHABAHTTEXTCAPSCA
(c:\Users...\Content.MSO\8BE508C6.docx)
It occurs at random in any of the files (you can be 10 files in or 100). I thought that it might be a problem with the files being on a network drive so I modified the program to copy each file locally first, add the footer to that copy, and then copy it back out to the network. However, that didn't seem to work. I'm looking for any suggestions on how to fix the problem or possibly rewrite the solution. However, I need to keep the solution in VBA since this app is part of a bigger suite which in not ready for a .NET re-write.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事实证明,我能够通过在本地复制单词文件,在本地副本上运行主代码,然后将它们复制回网络来解决这个问题。它一开始似乎不起作用,因为我测试它的用户机器没有该程序的最新版本。
As it turns out I was able to workaround this problem by copying the word files locally, running the main code on the local copies, then copying them back out to the network. It didn't seem to be working at first because the user's machine on which I tested it did not have the most recent version of the program.
为那些仍在寻找此错误答案的人添加此注释...
我有一个宏,可以根据主文档中的部分从打开的文档创建多个文档。
我收到运行时错误“5096”,并且能够找到任何有效的解决方案。
在调试代码时经过进一步检查,我发现在从主文档中提取数据并构建文件名时,文件名后面和扩展名之前有一个回车符。添加替换语句以删除回车符后,我能够全天处理文档而不会出现错误。
Adding this note for those still looking for answers to this error...
I have a macro that creates several docs from one that is open based on sections in the main document.
I was getting the Run-time error '5096' and was an able to find any solutions that worked.
Upon further examination while debugging the code I discovered that while pulling data out of the main doc and building a file name that there was a carriage return after the file name and before the extension. After adding a replace statement to remove carriage returns I am able to process documents all day without an error.
我发现该错误是由于文件名中的总字符数太长引起的。当操作文件名并且在变量中设置完整路径时,通常会发生这种情况。我将手动从真实的长名称中删除部分以强制其工作。
我想如果我聪明的话,我会进入目录并只处理文件名,而不在名称前面加上目录。
I have found that the error is caused by the total number of characters in the file name is too long. This usually occurs when manipulating file names and the full path is set in the variable. I will manually chop pieces out of real long names to force it to work.
I suppose if I were smart, I'd move into the directory and just deal with the file names without the directory prepended to the name.