>> Reference to Shell Cmd Object

G

Guest

Hi, in an earlier post regarding opening a database with a specific version
of access.exe when more than one is installed on a workstation, the response
was...

If you have multiple versions of Acess installed and want to ensure you end
up using the same one:
Call Shell(SysCmd(acSysCmdAccessDir) & _
"msaccess.exe C:\MyPath\MyFile.mdb", vbNormalFocus)

(Thanks Allen Browne)

My question is, is there a way to set an object reference to the access
session loaded using this Shell command?

Any ideas or suggestions appreciated :)

Many thanks, Jonathan
 
G

Guest

Alex Dybenko said:
Hi,
Try to use GetObject("C:\MyPath\MyFile.mdb")
or GetObject(,"Access.Application")

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Hi Alex, I wish it was as simple as that. The situation is that I want to
run a process from one application written in Access 97 (and will stay in 97
for another 6 months...) that creates .mde applications that can be in later
versions (2000, 2002, 2003). An .mde application can only be created using
the version of Access in which it was developed. That is, I cannot use Access
2003 to create a .mde file for an application developed using Access 2000; I
must use Access 2000.

So, I want to load the version of Access in which an application was created
and set a reference to this application. Using GetObject does not seem to
allow me to include a path to a specific msaccess.exe.

Many thanks, Jonathan
 
J

John Nurick

Surely:
Set oA97 = CreateObject("Access.Application.8")
Set oA2003 = CreateObject("Access.Application.11")
etc.
 
G

Guest

Hi John, thanks for this suggestion... this works for Access 97
(Access.Application.8) and Access 2003 (Access.Application.11).

I'm still looking for a solution for Access 2000 and Access 2002. Maybe
there isn't one. Maybe the above is really loading the MS Jet and so not
explicitly referenced by Access version?

Many thanks, Jonathan
 
J

John Nurick

If Access 97 is version 8 and Access 2003 is version 11, I'll leave it
to you to calculate the version numbers for Access 2000 and 2002.
 
G

Guest

<grin>thanks John, I do appreciate that sometimes the obvious does need to be
re-iterated</grin> actually I did try using Access.Application.9 and
Access.Application.10 before posting my response.

Jonathan
 
J

John Nurick

If you've surmised that I only have Access 97 and Access 2003 installed,
you were right, so I can't investigate the intermediate versions. Have
you checked whether there are registry entries for all four
Access.Application.X classes? If they're missing - or even if they're
not - it would be worth searching the MS Knowledgebase and Google Groups
for information on re-creating/repairing them.
 
A

Alex Dybenko

Hi,
yes, this is problem in 9,10 and 11 version of access. I have all 3
installed, and if I run this code (from Word for example):
set a=createobject("Access.Application.11")
?a.syscmd(7)
a.quit

I get a version of access, which I have run last (9 or 2000, in my case)

if you run several access versions same time - then results of createobject
becomes unpredictable.

so perhaps you can try to use shell to run certain version of access, and
then GetObject("C:\MyPath\MyFile.mdb") to get a pointer to it

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
G

Guest

Thanks Alex and John. The solution is to use shell combined with appActivate
and/or a wait (as there maybe a deley in loading) to open the correct version
of access and then use getobject to set a reference to it.

Many thanks
Jonathan

Alex Dybenko said:
Hi,
yes, this is problem in 9,10 and 11 version of access. I have all 3
installed, and if I run this code (from Word for example):
set a=createobject("Access.Application.11")
?a.syscmd(7)
a.quit

I get a version of access, which I have run last (9 or 2000, in my case)

if you run several access versions same time - then results of createobject
becomes unpredictable.

so perhaps you can try to use shell to run certain version of access, and
then GetObject("C:\MyPath\MyFile.mdb") to get a pointer to it

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top