Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Access with Workbooks.Open Method

Status
Not open for further replies.

hgrays

MIS
Nov 25, 2002
8
US
I have a procedure that launches another application and exports a data file in Excel format. The same procedure then attempts to Open the file using the Workbooks.Open method. Before opening the file, I check to make sure it exists using the Dir() function (this helps to ensure that the export action didn't fail). Most of the time this works great, however, occasionally the Open method will fail because the file is inaccessible (i.e. the exporting application has created the file, but not yet completed the export and thus has not released the file). I'd like to find a way to check that the data file not only exists, but is accessible, increasing the odds that my Open method will complete successfully.

Anyone have any ideas?
 
How do you launch the other application? Can't you wait for the application to complete before going on with opening the workbook?
Rob
[flowerface]
 
I'm launching the other application using the SHELL() function. This particular application (Oracle Discoverer) has a batch mode command line option which allows you to generate export files without user intervention. This batch mode also creates no window, leaving behind only the process running in the background. I'm not sure how to wait for the process to end since Excel really detects no process. I thought about a Windows API, but don't know which one would work. Thanks for the replies...
 
I'm sure I've seen a way before to shell out to another app and wait until it's completed, but I can't seem to find a reference to it any more. If all else fails, you could communicate between the two apps in some other way, such as having the shelled app create an empty file to signal when it's done, or update a registry entry.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top