Solved

VBA: Checking and closing an Excel file from Access

Posted on 2004-09-02
3
1,375 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
Comment Utility
0
 
LVL 9

Accepted Solution

by:
samopal earned 100 total points
Comment Utility
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
Comment Utility
Hi D'Al,

Thanks! Your code did exactly what I needed.

shanesuebsahakarn,

Thanks for the reply as well!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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 …

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now