Calling Internet Explore from MATLAB and same also for FireFox too

Does anyone know how Calling Internet Explore from MATLAB and same also for FireFox too? and how reading an .html by them

 채택된 답변

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

nice
i need reading an .html file with this that when i use 'fileName.html' instead of myurl, it can't open that
You need to provide the full path to the .html file, like you would in Firefox. For example 'file:///C:/My Documents/file.html'.
perfect! it could be open but couldn't be linked with MATLAB
this .html file has some hyperlink arrays when clicking on them in built browser in MATLAB, do some command but when clicking on them in IE, it says page not find
I get:
'iexplore' is not recognized as an internal or external command,
operable program or batch file.
Does it go by another name?
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.
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개)

Fangjun Jiang
Fangjun Jiang 2011년 9월 23일

1 개 추천

How about web() with -browser option.
help urlread

댓글 수: 1

Now I am using it but it's not flexible in searching like firefox

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

질문:

2011년 9월 23일

댓글:

2014년 4월 7일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by