MATLAB: Using ActiveX to copy and paste from a website

activexexeccommand

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');
end
When I use the function I get this Error:
No appropriate method, property, or field execCommand for class Interface.JScriptTypeInfo_JScript_Type_Info.
Error in CopyPasteIE (line 6)
ha.document.execCommand('selectall','','');
What needs to change so that this function will work? I still use MatLab R2014a if it makes any difference.

Best Answer

According to the MSDN documenation of the document property, what it returns depends on the type of the page that is loaded.
The example you linked assumes the page loaded is a html page, in which case document returns a IHTMLDocument2 compatible interface, which has a method ExecCommand.
In your case, I would guess that the page loaded is a javascript file, hence document returns a JScriptTypeInfo interface which is something completely different (for which I can't find much documentation).
Note that automating internet explorer is not particularly well documented and now that internet explorer has been deprecated, it's going to get harder and harder to find documentation.