MATLAB: How to copy a figure containing Activex control elements to the Windows clipboard using the HGEXPORT function in MATLAB

activexclipboardMATLAB

I am creating a figure containing an Activex Control element:
f = figure('position', [300 300 600 500]);
cal = actxcontrol('mscal.calendar', [0 0 600 500], f);
Then I copy the figure to clipboard using the following command:
hgexport(f,'-clipboard');
However, when I try to paste it to a Microsoft Word document, I do not get the expected image.

Best Answer

The ability to copy a figure containing Activex control elements to clipboard is not available in MATLAB.
To work around this issue, you can create an image of the figure containing the control and export that, as follows:
f = figure('position', [300 300 600 500]);
cal = actxcontrol('mscal.calendar', [0 0 600 500], f);
F = getframe(f);
[X,Map] = frame2im(F);
figure;
imshow(X);
hgexport(gcf,'-clipboard')