PDA

View Full Version : Close an Open Access database using Excel vba



febrero127
10-22-2015, 10:16 AM
My goal is to close an already opened access database when Excel Opens. Before anyone asks why I am doing this, its because my excel file has a connection tied to this specific db that is opened.
The connection data that my excel file contains does not refresh if the db that is trying to connect is openend. Please help I am not too good with vba.

This one seemed to work but this actually opens the database (a copy) and then closes the copy, not the already opened db:



Dim accessApp As Object
Set accessApp = GetObject("c:path", "Access.Application")
accessApp.docmd.Quit
Set accessApp = Nothing


This one does not work and it gives me an error Object required:



Dim accessApp As Object
Dim s As String
s = "c:path"
Set accessApp = GetObject(s)
accessApp = docmd.Quit

jonh
10-22-2015, 12:14 PM
with getobject(,"access.application")
.quit
end with

mancubus
10-23-2015, 12:51 AM
pls dont duplicate threads
in Excel Forum:
http://www.vbaexpress.com/forum/showthread.php?54070-Excel-code-to-close-an-already-openend-access-database