D
Dr Rubick
I'm trying to write a procedure in Excel to open Microsoft Access (if it is
not already open), then open a particular database (if it is not already
open, or open a new instance of access if the existing one has a different
file), and return an object handle to that database (leaving it open). I
already have a string variable with the full filename and path of the desired
database. It sounds simple enough, but it is proving very difficult to do.
I've tried using "GetObject", with error-trapping to use "CreateObject" if
"GetObject" fails. The problems are that if I use "CreateObject", then (1)
sometimes the "accObj.Visible = True" line crashes, and (2) Access will often
close when my macro ends, and I can't find a way to make it stay open.
I could probably keep trying different things until something works, but I
feel like I'm re-inventing the wheel here. Does anyone have sample code that
will do this?
not already open), then open a particular database (if it is not already
open, or open a new instance of access if the existing one has a different
file), and return an object handle to that database (leaving it open). I
already have a string variable with the full filename and path of the desired
database. It sounds simple enough, but it is proving very difficult to do.
I've tried using "GetObject", with error-trapping to use "CreateObject" if
"GetObject" fails. The problems are that if I use "CreateObject", then (1)
sometimes the "accObj.Visible = True" line crashes, and (2) Access will often
close when my macro ends, and I can't find a way to make it stay open.
I could probably keep trying different things until something works, but I
feel like I'm re-inventing the wheel here. Does anyone have sample code that
will do this?