Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 17th, 2009, 10:39 AM
Authorized User
 
Join Date: Jun 2007
Location: Tehran, Tehran, Iran.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to embed Word document in HTML page!

Hi everybody

I Have to display a word document in my webpage. Our web application is running under trusted security policy with full permissions (on an intranet). All browsers are IE. There is a way (as I knew) using OBJECT tag. I know how to use this tag to include external objects on my HTML page (like SWF, PDF, etc). But it seems it doesn't work for Word documents. I'm trying the following code (simplified here) on different clients having Office 2003 or 2007 installed, using doc/docx file type:

<html>
<body>
<object id="msword" width="100%" height="100%"
classid="CLSID:00020906-0000-0000-C000-000000000046"
data='http://localhost/testword/test.doc'>
</object>
</body>
</html>

When I open this page on my browser, it loads successfully without any error. But nothing appears on screen. It seems that Word object is loaded by browser (I can see WINWORD.exe on my process list using Task Manager) and fills the given area on the screen. I mean, when I right-click on different regions of my page, all the regions occupied by word object, prevents browser context menu to appear. Also the given file is downloaded from server successfully (as I changed the file address to some invalid name, a red cross apeared in place of Word object, indicating 404 HTTP error).

Some guys suggest to use IFRAME instead of OBJECT tag and set its src to given doc file. But in this scenario, browser tries to save/open given file and save/open dialogue appears on screen.


Now, I don't know what should I do and what to try.

- Is it possible to display a word document in HTML page in this way or it's completely impossile due to some technical issues ?
For example, Word OLE mechanism may not support to be hosted on a container like IE. This is my guess because when I try to open a pdf document using browser's file open dialogue, IE loads Adobe Acrobat Reader inside itself through OLE mechanism and let it handle displaying pdf file by itself. But when I try the same for a doc/docx file, file save/open dialogue appears and browser tries to download and save/open the given document.

- Do I have to try some special attributes on my OBJECT tag ?
I've already tried type attribute with different mime-type values I'd found for doc/docx document, but nothing happened

- Should I set some special mime-type on my server so that IE knows what is coming from server side?
As IE uses client's windows registery to lookup clsid of Microsoft Word, I think it's reading a mime-type associated to this clsid too.

However, I'm waiting for you guys. Please help me or tell me that it's completely impossible and make me relax
__________________
Ehsan Zaery Moghaddam
Senior J2EE/Web Developer
Reply With Quote
  #2 (permalink)  
Old March 7th, 2014, 09:54 AM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default RE: How to embed Word document in HTML page

Hi, I used that approach which was suggested to you (with IFRAME) and it worked on newer version of Chrome, so my guess is that it didn't work for you because that version of browser you used did not have a good support for iframe elements.
Sidenote, I'm not sure if embedding an actual document on a page is wise, someone mentioned me to avoid this and use some alternatives.
For example my requirement was only to let users preview on ASP.NET website a Word file, so I just converted it to HTML and rendered it instead.
Reply With Quote
  #3 (permalink)  
Old March 23rd, 2017, 07:23 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2017
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Microsoft Word can save its files as either documents or Web pages. If you want to embed a file's content into a larger Web page on your company site, you can extract its HTML code and paste it into your page. If you'd rather people access the file exactly as it appears in the Word document, as would be the case when you share an extended company report, you can embed the document as a link so that users can download the original file.
Embed as HTML

1. Open your document in Microsoft Word and then press "Alt-F-A" to open the Save As dialog box.

2. Click the "Save as Type" drop-down box. Select "Single file Web page" and click "Save."

3. Open the MHTML file you just created, using a text editor such as Notepad or an HTML editor such as Dreamweaver. Open your Web page code in a second window or tab.

4. Copy the code between the "<style>" and "</style>" tags in the MHTML document and paste the code into the corresponding style section of your Web page.

5. Copy the content that appears between the "<body>" and "</body>" tags in the MHTML file and paste it before the closing "</body>" tag in your Web page.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
export asp.net page to ms word and embed images Itech ASP.NET 2.0 Professional 2 March 6th, 2014 03:39 AM
Converting Word Document into HTML using jsp gharikishore9 Pro JSP 1 July 1st, 2006 08:25 PM
problem in word document converts to html or aspx yoord BOOK: Beginning ASP.NET 1.0 0 October 11th, 2004 07:08 AM
How show Word Document in One of the Frames page Umashankar R VB.NET 2002/2003 Basics 1 September 12th, 2004 10:36 PM
embed images in html allang Pro JSP 0 August 22nd, 2004 10:43 PM



All times are GMT -4. The time now is 12:26 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.