Office Library

S

scorpion53061

Does anyone know of a code sample or explanation of how to find the Office
Library (is it 8,9,10,11) on an indiviual computer.

This code detects if it is installed but I am not sure if it will detect if
the right version is installed.. My end user needs Office 2000 or above
versions of excel and word for them to use the reporting functions. If not I
need to disable them. (the reporting functions, not the end user.....:))

Public Enum MSApplications
WORD
EXCEL
End Enum

Public Function isInstalled(ByVal App As MSApplications)
Dim strSubKey As String
Select Case App
Case MSApplications.EXCEL
strSubKey = "Excel.Application"

Case MSApplications.WORD
strSubKey = "Word.Application"
End Select

Dim objKey As RegistryKey = Registry.ClassesRoot
Dim objKey1 As RegistryKey = Registry.ClassesRoot
Dim objsubKey1 As RegistryKey =
objKey1.OpenSubKey("Excel.Application")

Dim objSubKey As RegistryKey = objKey.OpenSubKey("Word.Application")
'does not work MsgBox(objKey.GetValue("Word.Application"))


Return Not objSubKey Is Nothing
objKey.Close()

Return Not objsubKey1 Is Nothing
objKey1.Close()
End Function
 
T

Terry Williams

Would you not want to scan the registry for the correct version keys ?

To get started, using Regedit, look under the following:

HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\OFFICE

Then create the code to look for certain key bits of information in this
part of the registry.
 
T

Terry Williams

I did a search in the help for 'Registry Key' I came across this. You
would want to change from CurrentUser to LocalMachine, but this should
get you going in the right direction.

Imports Microsoft.Win32
Dim regVersion As RegistryKey
Dim keyValue As String
keyValue = "Software\\Microsoft\\TestApp\\1.0"
regVersion = Registry.CurrentUser.OpenSubKey(keyValue, False)
Dim intVersion As Integer = 0
If (Not regVersion Is Nothing) Then
intVersion = regVersion.GetValue("Version", 0)
regVersion.Close()
End If
The following example reads, increments, and then writes a DWORD value
to HKEY_CURRENT_USER:

Imports Microsoft.Win32
Dim regVersion As RegistryKey
regVersion =
Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\TestApp\\1.0",
True)
If regVersion Is Nothing Then
' Key doesn't exist; create it.
regVersion =
Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\TestApp\\1.0")
End If

Dim intVersion As Integer = 0
If (Not regVersion Is Nothing) Then
intVersion = regVersion.GetValue("Version", 0)
intVersion = intVersion + 1
regVersion.SetValue("Version", intVersion)
regVersion.Close()
End If
 
T

Terry Williams

Test Code... It works.... Hope this helps you.


Dim regVersion As RegistryKey


regVersion =
Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Office\\9.0\\Exce
l", False)
If regVersion Is Nothing Then

MsgBox("Not there")
Else
MsgBox("Got it")

End If
 

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