Determine if Project is installed (1 Viewer)

scottfarcus

Registered User.
Local time
Today, 23:48
Joined
Oct 15, 2001
Messages
182
I am building an application that has the ability to export some data to MS Project in order to produce a Gantt chart view of a set of records.

In order to do this, the database must have a reference set to the MS Project object library. This works beautifully on my machine, but I'm afraid, once deployed, this application may find its way to a machine without Project installed. This will cause major errors, not only when you click the button to export the data, but, more importantly, on open of the application rendering the database useless.

I have discovered how to set and remove references on the fly using VBA, but I still have a problem: Setting a reference on the fly requires knowledge of the location of the .olb file. In most cases this will be in C:\Program Files\Microsoft Office\etc., but there is always the possibility that the end-user did not choose to install Project or Office in the default directory or even the default drive.

1) How can I determine if Project has been installed?
2) How can I locate the necessary .olb file in order to set my reference?
3) Would you recommend using an optional install? (ie., If you have Project installed, click here. If you do not have Project installed, or are not sure, please click here.) thereby installing one of two different versions of the application?

Any help appreciated.

Thanks in advance.
 

Travis

Registered User.
Local time
Today, 15:48
Joined
Dec 17, 1999
Messages
1,332
Use the Registry

Microsoft stores its applications install root paths in the windows registry.

Check out this web site for code to read the registry.
VBNet
 

scottfarcus

Registered User.
Local time
Today, 23:48
Joined
Oct 15, 2001
Messages
182
Travis,

Thanks for the reply.

True for Office apps, not for MS Project.

Any other suggestions?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:48
Joined
Feb 28, 2001
Messages
27,189
You can use the FileFind function to search the disk for a selected file name. At least in the case where FileFind fails, you have good odds that Project was NOT installed. Don't know exactly where to go if FileFind actually finds it, though.

Perhaps you could look for the correct name of the MS Project executable. You could search your own registry to find the name or name fragment of the key that Project uses when it is installed, then write some VBA code to read the registry looking for that key.
 

Tim K.

Registered User.
Local time
Today, 23:48
Joined
Aug 1, 2002
Messages
242
Try this out.

Code:
Sub ExistenceProjectCheck()
   Dim objApp As Object
   Dim strNotFound As String
   Const ERR_APP_NOTFOUND As Long = 429

   strNotFound = "Project is not installed on this machine. " _
      & vbCrLf & "Unable to automate Project."

   On Error Resume Next
   ' Attempt to create late-bound instance of Project application.
   Set objApp = CreateObject("Project.Application")
   
   If Err = ERR_APP_NOTFOUND Then
      MsgBox strNotFound
      Exit Sub
   End If
   
   With objApp
      ' Code to automate Project here.
      MsgBox "Project is installed. "
      .Quit
   End With
   Set objApp = Nothing
End Sub
 

Users who are viewing this thread

Top Bottom