Calling Internet Explore from MATLAB and same also for FireFox too
4 次查看(过去 30 天)
显示 更早的评论
Does anyone know how Calling Internet Explore from MATLAB and same also for FireFox too? and how reading an .html by them
0 个评论
采纳的回答
Kaustubha Govind
2011-9-23
Try:
myUrl = 'www.mathworks.com/index.html';
ieCmd = ['iexplore ' myUrl];
ffCmd = ['firefox ' myUrl];
system(ieCmd);
system(ffCmd);
Both iexplore.exe and firefox.exe should be on the system PATH variable.
6 个评论
Kaustubha Govind
2014-4-4
Perhaps iexplore.exe is not on your System PATH. You could right click on your desktop/Start menu Internet Explorer icon, select "Properties" to see the full path to the application.
Image Analyst
2014-4-7
I found the file here: C:/Program Files (x86)/Internet Explorer/iexplore.exe. Evidently that's not on the path, probably because it's a 32 bit program on a 64 bit computer. It works if I put in the full path. Just to be sure, I put in some Active X code to try if it fails to find it. Here is my final code:
myUrl = 'http://blah-whatever.com/statserver/R/default.asp';
iePath = '"C:/Program Files (x86)/Internet Explorer/iexplore.exe"';
if exist(iePath(2:end-1), 'file') % Don't include double quotes in the path we send to the exist() function or it won't find the file.
% Copy filename to the clipboard
clipboard('copy', excelFullFileName);
% Launch using the system() command.
ieCmd = sprintf('%s %s', iePath, myUrl);
system(ieCmd); % User pastes in filename when this page loads.
else
% Didn't find it. Try to let the system find it.
% Launch using CopyPasteIE() function which uses ActiveX to try to find it.
CopyPasteIE(myUrl)
end
Here's the ActiveX function:
% The following example uses the ACTXCONTROL command to call Internet Explorer.
% 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.
% Reference is a web page on the Mathworks server:
% http://www.mathworks.com/matlabcentral/answers/92736-is-there-an-example-of-how-to-call-microsoft-internet-explorer-as-an-automation-server
% Note: The code provided in this example is for demonstration purposes and has not been thoroughly tested.
function str = CopyPasteIE(url)
try
str = [];
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');
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
WarnUser(errorMessage);
end
return; % from CopyPasteIE
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!