Workbook.Open doesn't leave an open Workbook

M

Mac Lingo

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
 
D

Dave Peterson

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?
 
M

Mac Lingo

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.
 
D

Dave Peterson

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top