One of the main reasons that you might need this is that Microsoft Excel and Word documents pervade. They are perfect media to store, display and distribute information and ideas.
A rather straightforward approach is to simply link that document up.
<a href="bank/sheet.xls" >some excel file</a>
Another approach is via JavaScript.
<script type="text/javascript">
function openExcel(strFilePath) {
var yourSite = "http://www.yoursite.com";
openExcelDocPath(yourSite + strFilePath, false);
}
function openExcelDocPath(strLocation, boolReadOnly) {
var objExcel;
objExcel = new ActiveXObject("Excel.Application");
objExcel.Visible = true;
objExcel.Workbooks.Open(strLocation, false, boolReadOnly);
}
</script>
To open a word document with javascript, go with the following code:
<script type="text/javascript">
function openWord(strFilePath) {
var yourSite = "http://www.yoursite.com";
openWordDocPath(yourSite + strFilePath);
}
function openWordDocPath(strLocation) {
var objWord;
objWord = new ActiveXObject("Word.Application");
objWord.Visible = true;
objWord.Documents.Open(strLocation);
}
</script>
Hi there, very helpful post!
I have a question – what does the 2nd argument in excelApp.Workbooks.Open(Location, FALSE, false) stand for? I understand the 1st and the 3rd one but the second one is not very clear – and I do not seem to find any useful details on msdn….
Hi Friend,
Very much thanks to you.
Thanks.
Raja.
I want to open the .doc file and I have used your above code, but when I run the application its show the following error
Microsoft jscript runtime error : Automatic server can’t create object
any suggestion
You need to change your security settings, just enable all your active x components
I want to open the .doc file and I have used your above code, but when I run the application its show the following error
Microsoft jscript runtime error : Automatic server can’t create object
any suggestion
to resolve your problem, enable the ActiveXObject by going to internetOpt-> Security-> custom level
i used the same code it is working fine in IE7 but it is not working in Mozilla can you give a solution to it. i try to get this using Open office plugin still i am unable to open
@Sekhar ActiveX plugins only work in IE. This code won’t work in Mozilla.
hi all.. can you please tell me the alternative to activexobject used in above code.. if i have to use it in other browsers..?
Can you send me how to fetch data from excel sheet into drop down using JavaScript. Its really very very very very urgent
thanks in advance
You need to use XMLHTTP instead of ActiveXobject.
Hi Deepak
Can u please post the code for this. How to use XMLHTTP instead of ActiveX.
I want to display the excel on to the browser using iframe. Can u please help me out.
Thanks
If possible on share the code…
I use this code It invokes an instance of Word but does not open my doc. Whas up with that?
L
Hey Can I use ActiveXObject on Linux machine.
Is there another way to to create object on linux machine except ActiveXObject.
Thanks
HI this works fine to open an xls file but is not working if i use it to open an xlsm file. ANy ideas on how to do that?
How can I enhance it to check if file is already open before opening it?
and how can i interact with an open excel app?