Hi,
Here is the code:
Each time I run my code and if DB.xls is open it halts the code.HTML Code:
Thanks for your help.
Jaz
Hi,
Here is the code:
Each time I run my code and if DB.xls is open it halts the code.HTML Code:
Thanks for your help.
Jaz
If the activeworkbook is DB.xls, there's no need to activaate it. Do you want to know if it's among the open workbooks?
Entia non sunt multiplicanda sine necessitate
Hello jazbath,
I am not sure if this is what you are after. This code will test if the file open is open or not. This code can also be used for testing if the file has been opened in a separate instance of Excel (Code from Microsoft article KB213383)
![]()
Function IsFileOpen(filename As String) Dim filenum As Integer, errnum As Integer On Error Resume Next ' Turn error checking off. filenum = FreeFile() ' Get a free file number. ' Attempt to open the file and lock it. Open filename For Input Lock Read As #filenum Close filenum ' Close the file. errnum = Err ' Save the error number that occurred. On Error GoTo 0 ' Turn error checking back on. ' Check to see which error occurred. Select Case errnum ' No error occurred. ' File is NOT already open by another user. Case 0 IsFileOpen = False ' Error number for "Permission Denied." ' File is already opened by another user. Case 70 IsFileOpen = True ' Another error occurred. Case Else Error errnum End Select End Function
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Hi Leith,
thanks for posting the code. I am not looking for something like this. I am running a code to collect data from a run sheet and put into DB.xls. So if DB.xls is already open I am trying to have the code just select DB. If not open DB.xls to input data.
Thank you
Jaz
Hello jazbath,
Will you be in Excel when you do this check for DB.xls?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks