LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default File or Window is open

Is there a way to tell if a file or window name is open in the current
session of excel and not use the full path. I have seen a routine written of
IsFileOpen()

If IsFileOpen("C:\History\Ac01\File001.xls") Then
'Do this
End If


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

I would like to just see if the window is open and not have to use the full
path name. Is that possible.

Thank you,

Steven

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista Office 2003 File Open Window @details will only show file n. amb@HKD Excel Discussion (Misc queries) 1 September 3rd 09 01:03 AM
refer to active window when more than one window open for a file mcambrose Excel Programming 4 November 17th 08 08:16 PM
open mht file - on all the window HS Charts and Charting in Excel 0 July 4th 05 01:15 PM
open file in different window Anna Excel Discussion (Misc queries) 1 April 25th 05 09:33 PM
Customize the File Open Window ToeBoy Excel Programming 1 July 26th 03 04:44 AM


All times are GMT +1. The time now is 06:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"