Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Checking for open workbook... | Excel Programming | |||
Checking to see if a Workbook is Open | Excel Programming | |||
Checking if workbook is open | Excel Programming | |||
Checking for Open Workbook | Excel Programming | |||
Using wildcard for checking whether files are open | Excel Programming |