run time error 4160 (solved, sort-of)

run time error 4160 (solved, sort-of)

Postby ChrisGreaves » 11 Jun 2011, 11:08

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.
The first five days after the weekend are always the hardest
Post=51822
User avatar
ChrisGreaves
PlatinumLounger
 
Posts: 4530
Joined: 24 Jan 2010, 23:23
Location: Yilgarn region of Toronto, Ontario, Canada

Return to VB/VBA/.Net

Who is online

Users browsing this forum: CCBot [Bot], HansV and 0 guests