Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2011, 03:47 PM
Authorized User
 
Join Date: Feb 2007
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Is Excel workbook open using Access

Is there code to see if an excel file is open? I want to export some data to an excel file and if the excel file is already open, then i'll exit the sub routine, if not then proceed with the export.

Thank you.
 
Old July 1st, 2011, 03:29 PM
Authorized User
 
Join Date: Mar 2011
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default

There is already some ideas out there on this subject. Most involve trying to open the file in a seperate function and lock it as you open it, which lock would fail if you already have it open, so a returned error would indicate that it was already open.

Here is one example I found:
http://www.exceltip.com/st/Determine...Excel/444.html

This works, although it returns false for any error (like a bad path name or some such thing). You might want to make sure you account for all other errors either in this function or before you use it rather than blindly assuming that any error means that the file is already open.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Excel from Access ppenn Beginning VB 6 1 February 23rd, 2010 08:42 AM
Excel 2003 VBA - Need to open a workbook in a fold bablhous BOOK: Excel 2003 VBA Programmer's Reference 0 December 21st, 2006 02:50 PM
Excel Workbook created from Access VBA clueless_may Access VBA 0 June 8th, 2004 09:42 AM
exporting a workbook from excel to access zisko3 Access 1 February 3rd, 2004 12:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.