Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Excel error 429 when running Matlab magic square example from Matlab builder

Subject: Excel error 429 when running Matlab magic square example from Matlab builder

From: Harsh Dhingra

Date: 24 Jul, 2010 20:46:03

Message: 1 of 1

Hi,

I was working with the Matlab builder magic square example (can be found in matlab builder users guide) in Matlab to compile and build m-files into COM objects for Excel. Essentially, the building process creates a .bas file which can be imported into Visual Basic Editor in MS Excel. In the VB code, the Matlab functions essentially end up being wrapped up inside COM objects and you can invoke these functions in the excel spreadsheet.

The example works successfully for output to a single cell. For outputing to multiple cells simultaneously, the code changes a little as a macros are instead used. This gives me error 429 ActiveX problem. I've got the same error on 2 different computers and different versions of Excel which leads me to believe its has something to do with the way i'm running it.

Any insight or help would be appreciated. I've attached part of the code below which comes from the Matlab builder magic square example. The line with the error is
CreateObject("xlmagic.xlmagicclass.1_0")
Thanks.


Dim MCLUtil As Object
Dim bModuleInitialized As Boolean
Dim xlmagicclass As Object

Private Sub InitModule()
If Not bModuleInitialized Then
On Error GoTo Handle_Error
If MCLUtil Is Nothing Then
Set MCLUtil = CreateObject("MWComUtil.MWUtil")
End If
Call MCLUtil.MWInitApplication(Application)
bModuleInitialized = True
Exit Sub
Handle_Error:
bModuleInitialized = False
End If
End Sub

Sub mymagic()
Dim R1 As Range 'Input value
Dim R2 As Range 'Output range

On Error GoTo Handle_Error
Call InitModule
Set R1 = Range("A2") 'Specify where the input value is.
Set R2 = Range("B2:E5") 'Specify that range for the output to use.
If xlmagicclass Is Nothing Then
Set xlmagicclass = CreateObject("xlmagic.xlmagicclass.1_0")
End If
Call xlmagicclass.mymagic(1, R2, R1)
Exit Sub
Handle_Error:
MsgBox ("Error: " & Format(Err.Number) & " Source: " & Err.Source & " Message: " & Err.Description)
End Sub

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us