I have written some marcos in Excell, which are looking checking my harddisk for documents, which start with a specific word. Then the document's path is split up and a hyperlink is set to the document as well.
This works fine for several documents, but as soon as I use "contrat*.doc" I get the above runtime error with the note: Application-defined or object-defined error.
The strange thing is that replacing the "o" with any other letter solves the problem, allthough replacing it wit "?" or "*" doesn't help.
I used the same exact code with other words and they all work fine. Any idea what that could be and how I can solve that?
Don't know, but a guess would be a very long filename that confusing/overloading the FileSearch object. Try putting a debug.print foundfiles(i) inside your for loop. You might be able to see which file it's tripping on. Use CTRL+G to view the immediate window.
you put me on the right track. I made a search in explorer for word documents of the name of "contrat*.doc" and found a document standing under X:. Once I moved this file into a subfolder, the macro worked fine.
Is that because I set the SearchSubFolders to TRUE?