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: 184
Default Loop Check for Workbooks already open

This loop thru all worksheets in the Folder works fine.
But the trapping of workbooks already open and their user names does
not, or it returns all workbooks names, like in my first test.
I do not want to have any intermediate halts and promptings.
I want after the last loop, a message displaying any workbook names
already open and their user.names.
Help appreciated,
J.P.
..
Sub CheckOpenWB()
On Error Resume Next
Dim SheetName As String, MyValue As String, defAnswer As String,
Source As String
Dim Dest As String, DestPath As String, Message As String, Title
As String
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
defAnswer = "08 - October"
Message = "Enter Source Workbook"
Title = "Source Workbook"
MyValue = InputBox(Message, Title, defAnswer)
DestPath = "P:\Cost Reports\"
If MyValue < Empty Then
Source = DestPath + MyValue
End If
Application.ScreenUpdating = False
Dim FoundFile As String
Message = ""
FoundFile = Dir(Source + "\*.xls")
Do While FoundFile < ""
Workbooks.Open Source + "\" + FoundFile, ReadOnly:=True
' Checking if workbook is already open
' This first test finds them all open, which is wrong
'If Err = 0 Then
'This second test gives an Invalid qualifier Error
If FoundFile.IsOpen Then
Message = Message & FoundFile & Application.UserName &
vbLf
End If
ActiveWorkbook.Saved = True
ActiveWorkbook.Close True
FoundFile = Dir()
Loop
Application.ScreenUpdating = True
MsgBox Message
End Sub
 
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
Check if Any workbooks are open Kevin R Excel Programming 3 September 13th 06 07:55 PM
Loop Through All Open Workbooks scott Excel Programming 11 February 1st 05 02:58 AM
Create a Loop to check cells between workbooks No Name Excel Programming 0 September 16th 04 04:35 PM
Loop through all Open workbooks Stuart[_5_] Excel Programming 3 June 7th 04 08:07 PM
Loop through open workbooks Bob Phillips[_6_] Excel Programming 2 April 28th 04 09:28 AM


All times are GMT +1. The time now is 01:18 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"