A Whirly Wiry Web article about Open Office from a Web Page - Override IE's default behaviour to open Office documents in the browser window. Authored by RockinFewl.
Query words: start office from html,start word from html,start excel from html,start word from web page,start excel from web page,start office from web page,launch word,launch excel,launch powerpoint,office activex,office application,microsoft office,automation.
This article applies to MSIE 4+ | Windows 9x, Me, NT,2000 | Intranet, Internet.
Article styled for generic XHTML1 capable agents. Parts considered incompatible are marked [Part not rendered to your browser].
You may obtain this article styled for Microsoft Internet Explorer 5+ here.
By default, Internet Explorer is configured to host Office documents.
A Microsoft Knowledge Base article, "Office Documents Open in Internet Explorer (Q162059)" tells how to permanently disable this feature.
However, sometimes we're only occasionally interested in starting up the appropriate Office program.
This article outlines a few scripts that will enable to start up seperate copies of the Office applications (Word, Excel and Powerpoint). We will also load a web document in these programs. This way, the user has all he needs to work with these documents before saving the copy to local media.
To accomplish the task, we will use client-side ActiveX objects that are automatically installed when Office is installed, so there's no need to do any client-side configuration to make this method work.
However, these components are not marked as 'Safe for Scripting', the result of this depends on the client's security settings.
When the page is hosted on a Intranet server, the scripts will generate a security warning. When the user clicks yes, the Office application will be started and de web document loaded.
To switch off this warning, consider to add the Intranet site to the client's Trusted Sites.
When the page is hosted on a Internet server, default security settings will prohibit to start these kind of components. The client will have no occasion to explicitly allow the start-up of Office applications.
To resolve this issue, consider to change the client's security settings for components 'not marked safe for scripting' from 'disable' to 'prompt'. Please do not change the setting to 'enable' as this blind acceptance is too dangerous on the Internet.
Personally, I'd advise against to use this kind of scripts from Internet sites.
<script language="JavaScript">
function startWord(strFile)
{
var myApp = new ActiveXObject("Word.Application");
if (myApp != null)
{
myApp.Visible = true;
myApp.Documents.Open(strFile);
}
}
</script>You can now start Word with a hyperlink:
<a href="javascript:startWord('http://yoursite/test.doc')">Test.doc</a>.
As Word is running locally, mind to feed a full URL as a parameter if you want to open a web document.
<script language="JavaScript">
function startExcel(strFile)
{
var myApp = new ActiveXObject("Excel.Application");
if (myApp != null)
{
myApp.Visible = true;
myApp.Workbooks.Open(strFile);
}
}
</script>You can now start Excel with a hyperlink:
<a href="javascript:startExcel('http://yoursite/test.xls')">Test.xls</a>.
As Excel is running locally, mind to feed a full URL as a parameter if you want to open a web document.
<script language="JavaScript">
function startPowerPoint(strFile)
{
var myApp = new ActiveXObject("PowerPoint.Application");
if (myApp != null)
{
myApp.Visible = true;
myApp.Presentations.Open(strFile);
}
}
</script>You can now start PowerPoint with a hyperlink:
<a href="javascript:startPowerPoint('http://yoursite/test.ppt')">Test.ppt</a>.
As PowerPoint is running locally, mind to feed a full URL as a parameter if you want to open a web document.
We gain from the fact that Office applications are fully Automation enabled. In fact, there are a lot more applications that can be communicated with this way.
Check out OLE Programmatic Identifiers at MSDN.
If you have corporate applications that feature the same kind of Automation interface, you may be able to do pretty much the same as shown here with Office.
The Office applications are started as seperate processes, with a user interface. This means that we can safely close the originating browser window; this won't close the Office application.
There's a lot more that can be done using the Office ActiveX interfaces. Start your exploration at MSDN!
DHTML Gems
Fine DHTML tricks that may save your day. (Script)
Fighting eZula
The Web author's war against contextual advertising. (Script)
Detecting TopText and Surf+
Detecting eZula TopText and Spedia Surf+ Enabled Browsers (Script)
The Revealing HTTP Headers
View HTTP server response headers and unprocessed HTTP content. (Tool)
Launch-in-IE
Web pages can start applications. Securely. (ActiveX)
Open Office from a Web Page
Override IE's default behaviour to open Office documents in the browser window. (Script)
ShellExe launches HTML files from AUTORUN.INF
A ShellExecute wrapper that delivers (Utility)
Stealth Browser-Server Conversations
Exchanging data with the server without a page refresh. (Script)
Whirly Wiry Web Today
News, mission, and more skinnies you might be interested in. (General)
Dockyard
Material in test. (-)
The Whirly Wiry Web is RockinFewl's test bed and showcase in one.
All content, code and graphics are entirely crafted at our own premises, but material can freely be reused if charming credit is given.
WhirlyWiryWeb.com, 2001-2006. Address comments to Rockin at WhirlyWiryWeb.com