Vb6 check file open
Is this best practice or can someone recommend another method? You say VB Script. Do you mean VBA? This is a VBA forum. If you mean VB Script then you probably should use a different forum. This is a VBA function I use to test if an xlsx or docx file is open. The content you requested has been removed. Ask a question. Quick access. Search related threads. Remove From My Forums. If it is open, or un-editable for any reason, you will be able to stop the macro from running or display a meaningful error message to the user.
Do you know the fastest way to learn foreign languages? It is to read, write, speak, and think in that language as often as possible. Apart from speaking, programming languages are no different. The more you immerse yourself in that language, the faster you will pick it up.
Therefore, what most people like you need is lots of examples that you can practice. The book contains:. By entering your email address you agree to receive emails from Excel Off The Grid. Do you need help adapting this to your needs? By taking the time to understand the techniques and principles in this post and elsewhere on this site you should be able to adapt it to your needs. What next? Check out the latest posts:. I found that this code does not work for files opened from network mapped drive.
Your email address will not be published. And that is what I'm trying to find here. It doesn't matter. What you are trying to do will not work as expected if the file belongs to a process that is using it in a certain way. Just move the file and duck. You are making too much of a simple thing. You cannot know if another process is using the file. Many file including most log files can be moved. The process will just recreate the file if it is not in place. If you get an error then the file cannot be moved.
This is all that is important. There is and cannot be a more efficient way. The whole concept on any OS is odd because you cannot move open file no matter what utility you use to get the status. The error you get is as fast or faster than any utility. We thought you wanted to know this because there are legitimate technical reasons to finding open files. What you want cannot be done with a script.
You can only do it with special changes to the OS. Just use the error. If a process is opening and closing a file for logging the chances are that it will test closed and yet be open the second you try to move it.
You still need to check for the error. Office Office Exchange Server. Not an IT pro? Resources for IT Professionals. Sign in. United States English. Ask a question.
Quick access. Search related threads. Remove From My Forums. Answered by:. Archived Forums. The Official Scripting Guys Forum! If your answer is "yes," you know what to do. Dive in and help somebody! If your answer is "no," welcome to our fun little world!
0コメント