[ 本帖最后由 好学 于 2007-11-19 11:26 编辑 ]作者: baije 时间: 2007-11-19 14:26
为什么要SysCmd(acSysCmdAccessDir) ?
直接:shell "msaccess.exe " & CurrentProject.Path & "\sjch.mdb"作者: 好学 时间: 2007-11-19 15:54
baije没有路径打不开啊!请试试作者: 好学 时间: 2007-11-19 16:17
还有我要补充说的是我是在VB打开ACCESS的,没有明确msaccess.exe 的路径打不开,想不到好的办法作者: andymark 时间: 2007-11-19 17:44
获取OFFICE的安装路径
Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
"RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) _
As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
ByVal lpReserved As Long, lpType As Long, _
ByVal lpData As String, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Const REG_SZ As Long = 1
Const KEY_ALL_ACCESS = &H3F
Const HKEY_LOCAL_MACHINE = &H80000002
Public Function OfficePath(OfficeID As String) As String
'用途:获取OFFICE安装路径
'用法: OfficePath "Access.Aplication"
Dim hKey As Long
Dim RetVal As Long
Dim sProgId As String
Dim sCLSID As String
Dim sPath As String
sProgId = OfficeID
RetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\Classes\" & _
sProgId & "\CLSID", 0&, KEY_ALL_ACCESS, hKey)
If RetVal = 0 Then
Dim n As Long
RetVal = RegQueryValueEx(hKey, "", 0&, REG_SZ, "", n)
sCLSID = Space(n)
RetVal = RegQueryValueEx(hKey, "", 0&, REG_SZ, sCLSID, n)
sCLSID = Left(sCLSID, n - 1) 'drop null-terminator
RegCloseKey hKey
End If
[attach]26956[/attach]作者: andymark 时间: 2007-11-20 17:02
用API,不需要判断ACCESS安装在那个盘
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long