OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Run macro from VB.Net 2005 (http://forum.oberonplace.com/showthread.php?t=1602)

jabky 30-06-2006 15:56

Run macro from VB.Net 2005
 
I am trying to run a macro from VB.net 2005 and I am getting the following error:
Retrieving the COM class factory for component with CLSID {4A110034-2109-4B5D-BC63-17AE8914E384} failed due to the following error: 80040154.
I have stripped out everything from the code except the following:

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myGMS As CorelDRAW.GMSManager
myGMS = New CorelDRAW.GMSManager
End Sub
End Class

If I comment out the myGMS = New CorelDRAW.GMSManager line, it does not throw the error.

Anyone know what may be causing this?

shelbym 30-06-2006 17:45

.Net
 
Take a look at this post by Alex, I think it might be your problem.

http://forum.oberonplace.com/showpos...59&postcount=2

Hope it helps,

Shelby

jabky 04-07-2006 07:40

Thanks Shelby for the reply. I saw the post Alex's earlier and hoped that it would help. However, I am not even getting far enough to pass parameters. VB.Net 2005 will not let me set up the GMSManager object. I tried it in VB6, and it worked fine. I think there is a disconnect between 2005 and CorelDraw. I was hoping that there is a fix. I think I will send a note to Corel tech support. Have any other ideas? They will be greatly appreciated. Again, thanks for the reply.

wOxxOm 04-07-2006 12:33

that link should resolve all your troubles which derive from the fact that there is no OLE registration for GMSManager in Windows, so the GMSManager object can be retrieved only by accessing CorelDraw Application object's property GMSManager as stated in that thread.

80040154 = Class not registered, standard OLE error
{4A110034-2109-4B5D-BC63-17AE8914E384} = virtual CLSID of GMSManager object which is not registered in CLSID database in Windows registry and should not of course

As far as I can clearly see there is no error in CorelDRAW though I didn't test it. Give an updated example of your code using technique by Alex, so we can help further

Or tell me - do you want to access GMSManager object without first initializing CorelDRAW Application object? if so then there is probably some quirk using CoCreateInstance WinAPI but I doubt that it can be done without manual fake registereing of GMSManager in CLSID....anyway why bother?

Alex 04-07-2006 21:37

Well, there are only a few classes that can be instantiated directly using New keyword or CreateObject method. Application class is one of those. The others are Color, ShapeRange, various import/export structs (e.g. StructSaveAsOptions), etc. All the rest of the classes are not creatable directly. The only way to get to them is through one of the creatable classes, namely the Application class.

It is not just a matter of registering a class under HKEY_CLASSES_ROOT\CLSID section of Windows Registry. This only tells OS what application is reponsible for creating an instance of that class. In addition, the application must provide a class factory - a special creator class for each creatable class of its object model. These class factories are registered with Windows at application startup and used to actually let an application create an instance of a class. Adding a registry entry for non-creatable class will not make CorelDRAW expose one more class factory for, say, GMSManager.

Just so you understand the whole thing a little better. Long story short, get hold of an instance of Application class and then get to any subobject you need.


All times are GMT -5. The time now is 17:16.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com