run time error 4160 (solved, sort-of)

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

run time error 4160 (solved, sort-of)

Post by ChrisGreaves »

VBA code that's been running since '97.
Suddenly clags with a Run Time Error '4160' Bad File name.
When the file name looks PurrFect to me:
1.png
http://www.tek-tips.com/viewthread.cfm?qid=1574915&page=12 gives the clue.
In the post stamped "21 Oct 09 5:26" Aviator9 says "The problem got fixed thanks to Pesach Shelnitz: The OriginalDocument and RevisedDocument parameters must be Document objects."

I changed my code from

Code: Select all

    If blnDocumentsOpenProject(docProject, strProject) Then
        If blnProtectedDocument(Documents(strProject)) Then ' RTE 4160
        Else
to

Code: Select all

    If blnDocumentsOpenProject(docProject, strProject) Then
''''        If blnProtectedDocument(Documents(strProject)) Then ' RTE 4160
        If blnProtectedDocument(docProject) Then
        Else
and the problem has gone away.
I'm still a trifle mystified.
This is an application that trawls folder trees looking for any sort of file that might contain VBA code (dot, doc, xls, xla, bas, cls, frm, txt etc) and just plods along, night after night.
One file, and it breaks.
P.S. The file was successfully opened, so it doesn't appear to be a corrupt file or a mis-extented file.
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace