|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Does anyone know of a way in Access XP, probably using Visual Basic code, to get the path and name of current Access program that is open? Basically, I am looking for something like "currentDB", which will tell me the path and name of the database which is currently open. But I want something like "currentAcc" to give me "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE". This is obviously unnecessary if Access is always intalled in the same directory, but that is unfortunately not always the case. The Microsoft help file mentions something on MACs running OS 7.0 or higher, but nothing for PCs. Any help?
|
|
#2
|
|||
|
|||
|
In Access VBA try
currentproject.name currentproject.path
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
Doug,
This gives me the name of the database that I have open, rather than the access program (msaccess.exe) that has opened it. It is th elatter that I need. Russ |
|
#4
|
|||
|
|||
|
RE: getting path and name of current Access program
Hello Russ,
You can get this path from windows registry key below: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE You may need to use API functions to accomplish this. GetSetting and GetAllSetting function in access are limited for this purpose. Hope it will help. |
|
#5
|
|||
|
|||
|
That may not correct. If you install different versions of MS Access, such as Access 97, Access 2000 and Access XP (2002), etc. at the same machine, you may have trouble. The value from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE may not be the path that you want. For my machine, I have installed three versions of MS Access. The path from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE points to Access 97.
The better way to fulfill your objective is as following: SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE" Quote:
|
|
#6
|
|||
|
|||
|
Thank You
Hello xidongzhang,Thanks for pointing that out! Just FYI: The value from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE will be updated depending on which version of Access you are loading. But I like your SysCmd, I just learn it for the first time. |
|
#7
|
|||
|
|||
|
I have a question. What if you're trying to load this with a setup script program (I use Inno Setup) and want to access the current Access EXE? Is my only route to use the registry key above and expect them not to have multiple installations installed? See, the reason I want to do this is I have a workgroup file for Access user-level security and, without setting the Access default workgroup file for every machine, you can/have to use a shortcut of "[directory of access exe]\MSACCESS.EXE" "[location of MDB]\db.mdb" /wrkgrp "[directory of workgroup file]\wrkgrp.mdw".
Inno Setup can read registry keys and system constants, but, of course, couldn't tell me internally what the default Access directory is. And to be able to have the setup program create a shortcut based on their current Access directory, it has to be personalized to the individual computer. Thanks for any help! |
|
#8
|
|||
|
|||
|
Can u
can you tell what is sysCmd ...? it gives an error message ... sub not defined...
i have coded :' msgbox SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE" is it correct? Arjun Quote:
|
|
#9
|
|||
|
|||
|
Quote:
Hope it works for you. |
|
#10
|
|||
|
|||
|
Quote:
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > getting path and name of current Access program |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|