开发者

Word error when processing multiple documents

开发者 https://www.devze.com 2023-02-06 05:46 出处:网络
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 20

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消