Why Excel VBA code crashes when using objects created through MATLAB Builder?
Show older comments
I developed an Excel Add-in that basically export the MATLAB functions that deal with graph (ex: create and plot a graph, find shortest path, highlight certain path and etc) to be available in Excel. For some reason Excel crashes when the user try to use the functions even directly in the worksheet as a formula or inside a VBA code as a function. Sometimes it works and sometimes it doesn’t (with the same input arguments). Does anybody has any idea about what could be the cause of this issue?
Important information to be considered:
- Add-in created through MATLAB R2015b 32-bit installed at windows 10 64-bit
- The Add-in was packaged successfully using Complier Library App
- MATLAB Runtime (correct version) installed on the user machine
- The Add-in was apparently installed successfully at the user machine (windows 10 32-bit MS Excel 32-bit) without errors
- The file ‘MyApplication.bas’ was successfully imported into the excel file


Bellow examples of the functions scripts:
function [path,dist]=findSP(S,T,W,StartNode,EndNode)
G=graph(S',T',W');
[path,dist]=shortestpath(G,StartNode,EndNode);
end
-----------------------------------------------------------------------------
function [path,dist]=seeWire(S,T,W,names,StartNode,EndNode,wire,X,Y)
G=graph(S',T',W',names');
[path,dist]=shortestpath(G,StartNode,EndNode);
p=figure('name','Wire Path');
set(gcf,'PaperPositionMode','auto');
set(p,'Position',[200 50 850 630]);
hold on
fig=plot(G,'XData',X','YData',Y','NodeLabel',G.Nodes.Name,'EdgeLabel',G.Edges.Weight);
highlight(fig,path,'NodeColor','r','EdgeColor','r','MarkerSize',4,'LineWidth',3);
title (wire)
hold off
end
-----------------------------------------------------------------------------
function p = AutoPlotHarness(S,T,W,names)
%Fuction to plot the harness layout without the XData and YData for the
%nodes
% This function will plot the harness using de Layout condition Force
G=graph(S',T',W',names');
Fig1=figure('name','Harness Layout');
set(gcf,'PaperPositionMode','auto');
set(Fig1,'Position',[200 50 850 630]);
hold on
plot(G,'Layout','force','NodeLabel',G.Nodes.Name,'EdgeLabel',G.Edges.Weight);
title ('Harness Layout')
hold off
p=1;
end
Regards Rodrigo Estrela
Answers (0)
Categories
Find more on Data Export to MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!