Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBA: Checking and closing an Excel file from Access

Posted on 2004-09-02
3
Medium Priority
?
1,436 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 400 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

783 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