Hi,
I use the following, (that I found on the web some time ago.)
************************************************************************
If ApplicationInstalled("Word.Application", 11) = False Then
MsgBox "The required version of Microsoft Word has not been found on
your computer.", vbExclamation + vbOKOnly, "Microsoft Word Not Found."
Else
'put your code here to perform task.
EndIf
************************************************************************
The value of 11 in the code above is for Office 2003. Just substitute in the
value for Office 2007. Is it 12?
I then have the following code in a module:
************************************************************************
Option Compare Database
Option Explicit
Public Const ERR_REG_READ As Long = -2147024894
Public Function PathToApplication(progid As String, _
Optional Version As Long = -1) As String
Const rkClsid As String = "HKLM\Software\Classes\{0}{1}\CLSID\"
Const rkServerPath As String = "HKLM\Software\Classes\CLSID\{0}\
LocalServer32\"
Dim strVersion As String
Dim strArg As String
Dim strResponse As String
'use early binding and set a reference to Windows Script Host Object
Model.
'for late binding, comment out the following line.
'Dim objShell As New IWshRuntimeLibrary.WshShell
'use late binding.
'for early binding coment out the following two lines.
Dim objShell As Object
Set objShell = CreateObject("wscript.shell")
On Error GoTo Err_Handler:
'If we passed a version value, create a version
'string we can pass to StringFormat (if no
'version value is passed, strVersion will remain
'empty and StringFormat will omit the version
'information
If Version <> -1 Then strVersion = "." & CStr(Version)
'expand the tokens and search for the registry key
strArg = StringFormat(rkClsid, progid, Nz(strVersion, vbNullString))
strResponse = objShell.RegRead(strArg)
If strResponse <> vbNullString Then
strArg = StringFormat(rkServerPath, strResponse)
strResponse = objShell.RegRead(strArg)
End If
'some servers are registered with arguments
'(/automation, etc); remove the arguments
If InStr(strResponse, "/") > 0 Then
strResponse = Trim$(Mid$(strResponse, 1, InStr(strResponse, "/") - 1))
End If
Cleanup:
Set objShell = Nothing
Terminate:
PathToApplication = strResponse
Exit Function
Err_Handler:
Select Case Err.Number
Case ERR_REG_READ:
PathToApplication = vbNullString
Case Else:
MsgBox Err.Description, vbCritical, Err.Number
End Select
'set an empty response string
strResponse = vbNullString
Resume Cleanup:
End Function
Public Function ApplicationInstalled(progid As String, _
Optional Version As Long = 0) As Boolean
'comment out the following line if you wnat to use early binding.
Dim fso As Object
'uncomment the following lines if using early binding above.
'Dim fso As New IWshRuntimeLibrary.FileSystemObject
'Dim fso As New objShell.FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
ApplicationInstalled = fso.FileExists(PathToApplication(progid, Version))
Cleanup:
Set fso = Nothing
End Function
Public Function StringFormat(fmtString As String, ParamArray args() As
Variant) As String
Dim i As Long
Dim strReturn As String
strReturn = fmtString
For i = LBound(args) To UBound(args)
strReturn = Replace(strReturn, "{" & i & "}", args(i))
Next i
Terminate:
StringFormat = strReturn
End Function
*********************************************************************************
Anthony