Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The comparison is case sensitive. Try this code...
Dim File_Name As String Dim book As Workbook File_Name = "fast05chts.xls" For Each book In Workbooks If LCase(book.Name) = File_Name Then Windows(File_Name).Activate Exit Sub End If Next book Workbooks.Open Filename:="D:\Fast05\" & File_Name, UpdateLinks:=True -- HTH... Jim Thomlinson "Roger B." wrote: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jim, many thanks. Your macro worked really well.
Roger "Jim Thomlinson" wrote in message ... The comparison is case sensitive. Try this code... Dim File_Name As String Dim book As Workbook File_Name = "fast05chts.xls" For Each book In Workbooks If LCase(book.Name) = File_Name Then Windows(File_Name).Activate Exit Sub End If Next book Workbooks.Open Filename:="D:\Fast05\" & File_Name, UpdateLinks:=True -- HTH... Jim Thomlinson "Roger B." wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Weird "If" result | Excel Discussion (Misc queries) | |||
2 level subtotal result weird | Excel Discussion (Misc queries) | |||
Advanced formula - Return result & Show Cell Reference of result | Excel Worksheet Functions | |||
vlookup based on random result returns incorrect result | Excel Worksheet Functions | |||
Array formula weird result | Excel Discussion (Misc queries) |