I want to lauch Access from my Vb.net program. Not get at the Access data -
actually open the Access frontend.
So I need to something like:
MSAccess.exe "MyDB.mdb"
I can get the path to Access, I found some code on the Microsoft site, which
I have posted below.
I need to know if the user has the full version - otherwise many of the
dotnet access interop functions will fail.
For example, Dim oAccess As Access.Application won't work unlesss full
access is present.
Users will full version of access will get more functionality from my
program. Runtime users will get all the features, as the Office.Interop
won't work.
'**********************************************
Public Function GetOfficeAppPath(ByVal sProgId As String, ByVal sEXE As
String) As String
'Returns path of the Office application. e.g.
'GetOfficeAppPath("Access.Application", "msaccess.exe") returns
'full path to Access. Approach based on Q240794.
'Returns empty string if path not found in registry.
' Enable an error handler for this procedure:
On Error GoTo ErrorHandler
Dim oReg As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.LocalMachine
Dim oKey As Microsoft.Win32.RegistryKey
Dim sCLSID As String
Dim sPath As String
Dim iPos As Integer
' First, get the clsid from the progid from the registry key
' HKEY_LOCAL_MACHINE\Software\Classes\<PROGID>\CLSID:
oKey = oReg.OpenSubKey("Software\Classes\" & sProgId & "\CLSID")
sCLSID = oKey.GetValue("")
oKey.Close()
' Now that we have the CLSID, locate the server path at
' HKEY_LOCAL_MACHINE\Software\Classes\CLSID\
' {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}\LocalServer32:
oKey = oReg.OpenSubKey("Software\Classes\CLSID\" & sCLSID &
"\LocalServer32")
sPath = oKey.GetValue("")
oKey.Close()
' Remove any characters beyond the exe name:
iPos = InStr(1, sPath, sEXE, CompareMethod.Text)
sPath = Microsoft.VisualBasic.Left(sPath, iPos + Len(sEXE) - 1)
Return Trim(sPath)
ErrorHandler:
Return ""
End Function