File status

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

From previous posts, I have seen how VBA code are written to determine
whether an Excel Workbook is opened. How to you write the VBA codes to
determine non-Excel file is opened say a PDF file opened with the 'Shell'
command?

Any help is very much appreciated.

Thank you.
 
Declare Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As
String, ByVal iReadWrite As Long) As Long

Declare Function lClose Lib "kernel32" Alias "_lclose" (ByVal hFile As Long)
As Long

Status = lOpen "Your PDF FILE.PDF", & H10 ' open for read write

1. if Status is a a number greater than zero, the file is not in use,
otherwise, the file is in use.
2. if Status is > 0, you will need to release it before you can use it:
lClose Status
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top