Solved

VBA: Checking and closing an Excel file from Access

Posted on 2004-09-02
3
1,410 Views
Last Modified: 2008-01-09
Hi Experts!

I have an access program that creates an excel file to log in any errors I have encountered while the program is running (I don't really open the excel file such that it shows in the taskbar). My question is how can I check if the excel file is open (active)? (Meaning it is open and it's in my taskbar) I want to be able to check if it's open and then be able to close the excel file to ensure that I won't get any errors while I use my program. I always end up with something going wrong in the program when the excel file I use is open. Hope I made sense.

Thanks in advance!

rusco
0
Comment
Question by:rusco
3 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11965301
0
 
LVL 9

Accepted Solution

by:
samopal earned 100 total points
ID: 11967394
Try this :

Dim xlBook As Excel.Workbook, xlApp As Excel.Application
Set xlBook = GetObject("Your Excel File Name")
Set xlApp = xlBook.Parent
xlBook.Save
xlBook.Saved = True
xlBook.Close
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing

Hope This Helps,
D'Al
0
 

Author Comment

by:rusco
ID: 11970210
Hi D'Al,

Thanks! Your code did exactly what I needed.

shanesuebsahakarn,

Thanks for the reply as well!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question