Workbook.Open doesn't leave an open Workbook
My Code:
TS = Directory & File_Name On Error Resume Next Workbooks.Open TS If Err Then Call MsgBox("Could not open " & TS & ", " & Err) End If After this runs, there is no Error Message, but there is no Workbook open either. This code works if I put in Workbook_Open, but not if I use it in a normal Function call. Any idea why it works in one place and not in another? Thanks, Mac |
Workbook.Open doesn't leave an open Workbook
Try
If Err< 0 Then HTH, Gary Brown "Mac Lingo" wrote in message ink.net... My Code: TS = Directory & File_Name On Error Resume Next Workbooks.Open TS If Err Then Call MsgBox("Could not open " & TS & ", " & Err) End If After this runs, there is no Error Message, but there is no Workbook open either. This code works if I put in Workbook_Open, but not if I use it in a normal Function call. Any idea why it works in one place and not in another? Thanks, Mac |
Workbook.Open doesn't leave an open Workbook
Your code worked ok for me.
Guess #1. Any chance that that TS was opened, but was hidden (or you didn't notice it)? Guess #2. Any chance that you have your own variable named Err? Mac Lingo wrote: My Code: TS = Directory & File_Name On Error Resume Next Workbooks.Open TS If Err Then Call MsgBox("Could not open " & TS & ", " & Err) End If After this runs, there is no Error Message, but there is no Workbook open either. This code works if I put in Workbook_Open, but not if I use it in a normal Function call. Any idea why it works in one place and not in another? Thanks, Mac -- Dave Peterson |
Workbook.Open doesn't leave an open Workbook
Thanks, Dave, for the response.
But the end result of the process is that the Workbook has not been opened from the code that is not in the Workbook_Open call. |
Workbook.Open doesn't leave an open Workbook
What happens when you step through the code (F8's)?
And if you look at the VBE, do you see the project for that workbook? And you did check under window|unhide to make sure it wasn't hidden? If you copy the significant portion of that code to a new workbook and run it there, does it work? How do you run this macro? Is it just alt-f8 and point and click or what? Mac Lingo wrote: Thanks, Dave, for the response. But the end result of the process is that the Workbook has not been opened from the code that is not in the Workbook_Open call. -- Dave Peterson |
All times are GMT +1. The time now is 09:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com