Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to: Open closed workbook/Search data tables/Return data to open workbook | Excel Discussion (Misc queries) | |||
how do i open a data workbook when i open a timesheet workbook | Excel Discussion (Misc queries) | |||
excel 2003 saved file will not open without a blank workbook open | Excel Discussion (Misc queries) | |||
How do you program so that Workbook B cannot be open unless Workbook A is open? Plus I need to validation | Excel Programming | |||
very difficult code that will close original workbook and leave another open | Excel Programming |