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

 Réponse acceptée

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 commentaires

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

Connectez-vous pour commenter.

Plus de réponses (1)

Fangjun Jiang
Fangjun Jiang le 23 Sep 2011
How about web() with -browser option.
help urlread

1 commentaire

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

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Report Generator dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by