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: 43
Default Checking for Open Files

I have a section of code that isn't executing and
I can't seem to figure out why...

Assume that the variable sStr hold the name
of a folder. I've checked this part and I know
that its working. When I run this section of code
with a file open it doesn't seem to be picking up
the Err = 0 piece, it just runs right past it.



Sub()

Dim fnStr,sStr as At String

With Application.FileSearch
.NewSearch
.LookIn = sStr
.SearchSubFolders = False
.Filename = ".xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
For j = 1 to .FoundFiles.Count
If WorkbookIsOpen(.FoundFiles(j)) Then
fnStr = .FoundFiles(j)
Workbooks(fnStr).Activate
ActiveWorkbook.Close([False])
End If


End With


Private Function WorkbookIsOpen(wbname) As Boolean
Dim X as Workbook
On Error Resume Next
Set X = Workbooks(wbname)
If Err = 0 Then WorkbookIsOpen = True _
Else WorkbookIsOpen = False
End Function
 
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
Checking for open workbook... Squid[_2_] Excel Programming 7 February 28th 04 01:16 AM
Checking to see if a Workbook is Open Todd Huttenstine[_3_] Excel Programming 4 December 25th 03 11:55 PM
Checking if workbook is open Jesse[_4_] Excel Programming 6 December 11th 03 11:17 PM
Checking for Open Workbook sbharbour Excel Programming 6 August 28th 03 11:42 PM
Using wildcard for checking whether files are open [email protected] Excel Programming 1 July 30th 03 06:47 PM


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

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

About Us

"It's about Microsoft Excel"