
Object variable or With block variable not set (Error 91)
Hi Iam trying to run the code below and get this error command. Can anyone
tell me ehat is wrong here.
Thanks
Option Explicit
Dim oMpApp As MapPoint.Application
Dim oMap As MapPoint.Map
Private Sub Command1_Click()
oMap.Shapes.AddShape geoShapeOval, _
oMap.GetLocation(49.01807, -121, 9), 10, 10
' Try to attach to running instance of MapPoint
On Error Resume Next
Set oMpApp = GetObject(, "MapPoint.Application")
On Error GoTo 0
If oMpApp Is Nothing Then
' Attaching failed - try creating an object
On Error Resume Next
Set oMpApp = CreateObject("MapPoint.Application")
On Error GoTo 0
If oMpApp Is Nothing Then
MsgBox "Could not create MapPoint object"
End
End If
' make the app visible
oMpApp.Visible = True
End If
' Ensure MapPoint survives when app terminates
oMpApp.UserControl = True
' Retrieve the active map
Set oMap = oMpApp.ActiveMap
End Sub