PDA

View Full Version : Cannot CreateObject("MapPoint.Application")



sharoma
10-06-2006, 05:25 AM
Hi, I am new to MapPoint and using MapPoint 2006. My very first line of MapPoint code throws an error "Run-time error '429': ActiveX component cannot create object"

Here is the code snippet:

Dim objApp As MapPoint.Application
Private MyMap As Map

On Error Goto logerr
Set objApp = GetObject(, "MapPoint.Application")
If objApp Is Nothing Then
Set objApp = CreateObject("MapPoint.Application")
objApp.Visible = False
objApp.UserControl = True
objApp.Activate
Set MyMap = objApp.NewMap()
End If


What am I missing in the code or is it a configuration issue.

Please Help.

Thanks

nearlydistant
10-06-2006, 11:03 AM
You need to add the Microsoft MapPoint 11.0 Object Library as a reference in the VBA window.

There is info on how to do this at the top of this page:
Excel User-Defined Functions and MapPoint - MapPoint Articles - MP2K Magazine (http://www.mp2kmag.com/a124--excel.udf.mappoint.html)

I was running into the same issue yesterday, and that was all I had to do to fix it.

Good Luck!

sharoma
10-06-2006, 11:42 AM
Thanks for reply.
I am using MapPoint 2006
I had already added the reference for "Microsoft Mappoint 13.0 Object Library (North America)"

Wilfried
10-06-2006, 12:55 PM
Hi,

GetObject generate an exception error 429 when the object is still not existand, see this page: GetObject Function (Visual Basic) (http://msdn2.microsoft.com/en-us/library/e9waz863.aspx)

So if you want to check if it exists already for eventually re-use then you have to place it into an exception block. Something like this:


Try
GetObject ...
Catch
CreateObject...
End

I dont know VB, so dont rely on the syntax :)

sharoma
10-06-2006, 02:59 PM
I commented that part but now it is throwing the same error at "CreateObject("Mappoint.Application")"

''''''Set objApp = GetObject(, "MapPoint.Application")
If objApp Is Nothing Then
Set objApp = CreateObject("Mappoint.Application")
Set MyMap = objApp.OpenMap("C:\ITMS\MAPSHARE\ITMS.PTM")
If (MyMap Is Nothing) Then
Set MyMap = objApp.NewMap()
End If
Else

Wilfried
10-07-2006, 03:55 AM
Hi,

I'm not sure if this is case sensitive: "MapPoint.Application"

However I see something else in your original post: "Run-time error '429': ActiveX component cannot create object". It seems that you use the ActiveX control also in your application, is that right ? Because as far as I know you can not mix the AcitveX control and the object model in the same application.

sharoma
10-09-2006, 10:02 PM
I tried so many things but nothing works.
Intrestingly the same code(literally as it is) works like a charm in MapPoint 2004.
However the same code fails to instanstiate the object(as the error 429 states) when run in MapPoint 2006.
Note: Interestingly the MapPoint.exe can be seen thru TaskManager.

Here are some of my observation.
My Source Code is in VB6 (SP5)
The VB6 Project adds reference to "Microsoft MapPoint 13.0 Object Library (North America). I am not using MapPoint.ocx to display any Map.

MapPoint 2004 software is using VC++6 DLLs
MapPoint 2006 software is using VC++7 DLLs

Not sure if my PC needs additional runtime files for VC++7 to run effectively.

Wilfried
10-10-2006, 02:31 PM
I am not using MapPoint.ocx to display any Map.

But wy is the error melding complaining about the AcitveX ?

sharoma
10-10-2006, 02:46 PM
Not sure. It fails at with error 429 at the line "Set objApp = CreateObject("MapPoint.Application")"

Wilfried
10-11-2006, 07:48 AM
Hi,

Eventually I do a test on my machine. At least we know then if it has something todo with the MapPoint installation. If you send the project to my personal email then I do a short test.

Wilfried
10-11-2006, 12:03 PM
Hi Sharoma,

I was hoping I could open your project with VS2005, but it is not. However I made new application in VB and copy the relevant part to see what happen. I only changed filenames and made the application visible to see if it works.

The only thing I had to do was add the type library to the project, however VS do not show me that it is added (but I dont know mutch of VB). Anyway this peace of code works here:


Public Class Form1

Private MyMap As MapPoint.Map
Dim objApp As MapPoint.Application

Private Sub UserControl_Initialize()
On Error Resume Next
objApp = GetObject(, "MapPoint.Application")
If objApp Is Nothing Then
objApp = CreateObject("MapPoint.Application")
MyMap = objApp.OpenMap("C:\Program Files\Microsoft MapPoint Europe\MP2004\Samples\Sales.ptm", False)
If (MyMap Is Nothing) Then
MyMap = objApp.NewMap()
End If
Else
MyMap = objApp.ActiveMap
If MyMap Is Nothing Then
MyMap = objApp.OpenMap("C:\Program Files\Microsoft MapPoint Europe\MP2004\Samples\Sales.ptm", False)
If (MyMap Is Nothing) Then
MyMap = objApp.NewMap()
End If
End If
End If

'objApp.Visible = False
objApp.Visible = True
objApp.UserControl = True
objApp.Activate()

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
UserControl_Initialize()
End Sub
End Class

I also see that your project is containing an *.ocx with same name as *.ctl file. And then the function name 'UserControl_..'. Maybe this has something to do with the error ?

Maybe other people with better knowledge of VB than me can answer here ?

sharoma
10-11-2006, 01:50 PM
Thanks
Looking at the line ===> MyMap = objApp.OpenMap("C:\Program Files\Microsoft MapPoint Europe\MP2004\Samples\Sales.ptm", False)

I hope you were using MP2006 and not MP2004.

As my project works fine with MP2004 but not with MP2006.

Wilfried
10-12-2006, 03:29 AM
Hi,

I forgot this. But just did the same test with MP2006. Same result it run here. I will email the project back together with the executable. Let's see if it run there.

sharoma
10-12-2006, 04:38 AM
Hi Wilfried, Unfortunately I only have two options for running the software.
(a) VB6 w/sp5
(b) VS2003

When I tried your above code sample in VS2003 it failed to run in MP2006 however it ran fine in MP2004.

This makes me think if there is an compatibility issue wrt MP2006 and VB6/VS2003

Wilfried
10-12-2006, 08:00 AM
Hi Sharoma,

It should work because you are using the type library. But I'm a little out of ideas now.

Did you try the executable I sent you together with my project ? Does it run on both mappoint versions ?

sharoma
10-12-2006, 12:35 PM
I cannot run your Application as it requires .NET 2. Where as I only have VS.NET2003

However your earlier sample project code works okay in MP2004 but not in MP2006

Wilfried
10-12-2006, 12:51 PM
Hi Sharoma,

Still we are not sure if it is something on your machine or with a VS2003 / VB6 setting. If you want you may send me an *.exe then I try it with MP2004 and then with MP2006 registeres.

If this works here then we know it is not VB/VS setting. Unless someone has a better idea ?

cwrude
10-19-2006, 10:21 AM
We experienced the same problem with some users who had been running an earlier version of MapPoint (2002 or 2004) on their PC, and then installed MapPoint 2006. After spending some time with Microsoft techs, the problem was discovered to be permissions-related. The solution was as follows:

1. Using RegEdit, change the permissions on HKEY_CLASSES_ROOT\.ptm and HKEY_CLASSES_ROOT\.ptt to Full Access for the Administrator. (to do this, right-click on the .ptm folder under HKEY_CLASSES_ROOT and select "permissions")

2. From command prompt, reregistered MapPoint using the command "C:\Program Files\Microsoft MapPoint\MapPoint.exe" /regserver.

The Microsoft tech said that he has seen this more than a few times with users running MP2006 who had previously been running an earlier version. He says that they are checking to see if this is, in fact, a bug with the MP2006 install routine. Good luck!

AUR
12-28-2006, 12:04 PM
Hi

There is no object in his control,

This is the message i used to receive in Access2003/VBA form integrated with MP2004 whenever i closed the form either manually or programmatically.

The form is working fine with all mappoint functionality, but i've to place the control again on the form.

This normally occurs when ur OCX control isnt displayed in the ACtive Xcontrols list, however its still there and i'm now stuck why it happens.

Any help would be greatly appreciated.
many thanks.
AUR

Wilfried
12-29-2006, 09:11 AM
Hi,

You cannot create object 'mappoint application' in parallel with the activeX control on a form.