Excel VBA Cannot get the object to be instantiated correctly

ImageMagickObject is a Windows COM+ interface to ImageMagick. COM+, Visual Basic, and Delphi users should post to this discussion group.
Post Reply
Wouter
Posts: 2
Joined: 2013-11-29T03:16:10-07:00
Authentication code: 6789

Excel VBA Cannot get the object to be instantiated correctly

Post by Wouter »

In Excel VBA I am trying to use the ImageMagick Object. The issue that I have is that I cannot get the object to be created correctly.

Either I get the message:
Run-time error '91': Object variable or with block variable not set
or when I change the way to declare the object:
Run-time error '429': ActiveX component can't create object

In Excel VBA Tools > References I added ImageMagickObject.dll which is nicely shown as ImageMagickObject 1.0 Type Library. I can also see the VBA editor can read the DLL, because when I type "Dim img as Ima", then to automatic completion offers the ImageMagickObject as an option and later when I hit "." then MagickImage is also available for auto completion.

I am running Windows 7 64bit with Office 2010 32bit. Initially I installed the default 64bit dynamic version of ImageMagick, as a test I installed the 32bit static 16 version (6.8.7-q16), also didn't work.

The Error 91 I get when I run below code(breaks at 'msg = img.Convert'):

Code: Select all

Sub sbExample1()
    Dim img As ImageMagickObject.MagickImage
    Dim SourceFile As String, DestFile As String
    Dim msg
    
    SourceFile = "something.jpg"
    DestFile = "something.jpg"
    msg = img.Convert(SourceFile, DestFile)
    Debug.Print msg
    Set img = Nothing
End Sub
The error 429 I get when I use:

Code: Select all

    Dim img As Object
    Set img = CreateObject("ImageMagickObject.MagickImage.1")
instead of

Code: Select all

    Dim img As ImageMagickObject.MagickImage
I got these two ways to use the object from different code samples online. I also tried to register with regsvr32 by going to the program folder in a command window and then run: regsvr32 ImageMagickObject.dll, it says The Specified Module could not be found. But it is right there and like I mentioned selecting it in Tools > References did make it show up in the References list.

I also tried to run SimpleTest.vbs which is in the tests folder of ImageMagickObject and I get error: 424 Object Required.

It is clear that something is blocking me from accessing this object, but I can't figure out what it is.

Anybody any ideas?
Post Reply