MATLAB: Is there an example of how to call Microsoft Internet Explorer as an automation server

MATLAB

I would like an example of how to use MATLAB and ActiveX to call Internet Explorer as an automation server.

Best Answer

The following example uses the ACTXCONTROL command to call Internet Explorer. Note: This may not work on newer versions of MATLAB as the COM interface for Internet Explorer may have changed.
This function takes in a URL as a string, loads the URL in Internet Explorer, copies the text from the URL, and returns the copied text as a string for use inside of MATLAB.
function str=CopyPasteIE(url);
ha = actxserver('internetexplorer.application');
ha.Visible = 1;
Navigate(ha, url);
pause(3); % Pause to let the page load
ha.document.execCommand('selectall','','');
ha.document.execCommand('copy','','');
str=clipboard('paste');
Note: The code provided in this example is for demonstration purposes and has not been thoroughly tested.