Thread: Weird result
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Roger B. Roger B. is offline
external usenet poster
 
Posts: 24
Default Weird result

I would like to know what is wrong with the following macro.
If Fast05Chts.XLS is closed it works but not if that file is open. Instead I
get a message that the file is open. This is strange when the 'exit sub'
should have prevented this.

Any suggestions would be appreciated.

Roger

Dim File_Name As Variant, book As Object

'Dim book As Variant
File_Name = "Fast05Chts.XLS"
For Each book In Workbooks
If book.Name = File_Name Then
Windows(File_Name).Activate
Exit Sub
End If
Next book

Workbooks.Open Filename:="D:\Fast05\" & File_Name, UpdateLinks:=True