View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Displayalerts and Screenupdating

Hari,

You are missing the point completely here. The problem is nothing to do with
FileSearch, nothing to do with ScreenUpdating. The problem is simply that
you cannot open 2 workbooks with the same name, even if they are in separate
directories.

You have 2 files with the same name, one in the top-level, one in a
subdirectory. Ignoring the code, open the first in Excel. Then try to open
the second. What do you get? Exactly the same error message.

William presumably turned the Screenupdating off to stop each workbook being
opened showing as it happened and causing a lot of flickering.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hari" wrote in message
...
Hi Harald and Bob,

Thanx a lot for ur replies. Im slightly more better off than in terms of
understanding than what I was before.

I posed a problem for automatic opening of excel files in a particular
folder and I got this code from William., wherein he has used

Screenupdating
feature.

I want to understand what is the role of screenupdating here.

Please tell me if possible . ( I modified the interior of the code

slightly
as compared to what William had given as I was getting compile error in

his
code. I used help feature to make this modification)

Also, I have one more doubt in this. Presently the code says
searchsubfolders as False. For experimental purpose I changed it to true

and
one of the subfolders had a excel file of the same name as in the root
folder. Inspite of this excel didnt display the message that 2 files with
same name cannot be opened.I thought this might be happeneing because of
Application.ScreenUpdating = False but as per ur explanation for
"Displayalerts and screenupdating" that would happen only if the code
mentioned about Displayalerts. Please tell me why excel doesnt display
messages for the below code.

Sub OpenWorkbooksInLocation()

Application.ScreenUpdating = False
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\CCAPPS\ttlview\TMP"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
.Execute
For i = 1 To .FoundFiles.Count
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
'Macro code for each workbook here
'wb.Save
'wb.Close
Next i
End With
Application.ScreenUpdating = True

End Sub


Thanx a lot