Detecting Installed Program

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a database that I share with others.
One of the forms does mapping and routing of the data via MS MapPoint. Can
someone tell me what code to use when someone tries to open that form to
detect whether or not Mappoint is installed on their machine so that I can
keep them from opening it if it is not.
(If you don't know Mappoint but could give me an example from another
program I can probably figure it out.)

Thanks
David
 
This is an example for Word...

Function IsWordInstalled() As Boolean

Dim obj As Object

On error resume next

Set obj = CreateObject("Word.Application")

IsWordInstalled = (Err.Number = 0)

End Function

Don't include a reference to MapPoint in your application...your code will
not run if MapPoint is not installed. However, you can use late binding
like the example above to obtain a MapPoint application object and
manipulate that (if it is installed). Google for "late binding" and see
help for CreateObject/GetObject.
 
Thanks Paul:
I think that starts me on my way - so in your example I would then put in
the on open event for the form something like:

If IsWordInstalled = False then
MsgBox 'blah blah'
close
end If

I guess I had been figuring by what I have gleaned from this discussion
group that I would need to figure out how to do late binding (I am not a
programmer at all) Looks like it's time to get started.

Thanks again,
David
 
Sorta...given your objective, I'd probably do the check within the same
procedure, i.e.,

Private mobjMapPoint As Object

Sub Form_Open()

On error resume next

Set mobjMapPoint = CreateObject("MapPoint.Application") 'not sure about
the classid, but you get the idea

If Err.Number <> 0 Then
msgbox "MapPoint is not installed. This application requires
MapPoint."
Docmd.Close
End if

'Do whatever here

End Sub

Note I'm setting a module level variable...I suspect you'll need to
manipulate the MapPoint object in procedures other than Form_Open.
 
Thanks - makes sense.
David

Paul Overway said:
Sorta...given your objective, I'd probably do the check within the same
procedure, i.e.,

Private mobjMapPoint As Object

Sub Form_Open()

On error resume next

Set mobjMapPoint = CreateObject("MapPoint.Application") 'not sure about
the classid, but you get the idea

If Err.Number <> 0 Then
msgbox "MapPoint is not installed. This application requires
MapPoint."
Docmd.Close
End if

'Do whatever here

End Sub

Note I'm setting a module level variable...I suspect you'll need to
manipulate the MapPoint object in procedures other than Form_Open.
 
Back
Top