Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default 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.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
how do i open a data workbook when i open a timesheet workbook [email protected] uk Excel Discussion (Misc queries) 2 January 4th 09 04:50 PM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
How do you program so that Workbook B cannot be open unless Workbook A is open? Plus I need to validation Marcello do Guzman[_3_] Excel Programming 2 December 5th 04 06:50 AM
very difficult code that will close original workbook and leave another open reesmacleod Excel Programming 4 December 3rd 03 11:21 PM


All times are GMT +1. The time now is 01:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"