none
Embed a MS Office document in HTML webpage

    Question

  •  

    I am having a problem with embedded objects in HTML. I would like to embed Word and Excel documents directly into a webpage so they do not open separately in Office.  I don't want links to the documents.  I have tried using the OBJECT tags in the HTML to "embed" it (Note: the EMBED tags do NOT work for embedding many objects...) but can't get it to work right.  I also want the embedded content to be scrollable and not just cut off if it is bigger than the containing object.  Here is the "code" I have so far:

     

    Code Snippet

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>">
    <html xmlns="<http://www.w3.org/1999/xhtml>">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Embedded Word Object Example</title>

    </head>

    <body>

     

    <object width="775px" height="500px" classid="clsid:00020906-0000-0000-C000-000000000046" data="sampleword.doc"></object>

    </body>
    </html>

     

    This will sort of work, but here are some problems:

     

    1) The content is not centered in the page with the rest of the content.

    2) The word document is clipped/ cut off.

    3) The object container is not scrollable.

    4) There are no other controls for the word document (not really necessary, but like a File menu with a Print option might be nice...

    5) Unsure if this is cross-browser compatible or not. It's not really an issue for the environment I'm making this for (All IE6 running on Win2k...) but if I can get something to work, it might be useful for other webpages that I would want to be cross-browser compatible.

     

    I have also tried changing the clsid of the OBJECT. The clsid used in the example above is from the Windows registry under Word.Document (in: HKEY_CLASSES_ROOT). I was thinking maybe I could embed the whole application with the clsid for Word.Application.8?

     

    Code Snippet

    <object width="775px" height="500px" classid="clsid:000209FF-0000-0000-C000-000000000046" data="sampleword.doc"></object>

     

    This does not work, however.  I'm thinking I need to pass it parameters with the PARAM tags to get it to open the file I want.  Maybe I can also pass PARAMs for which menu options I want, etc?  I just don't know what the name-value pairs are that I need to do this.

    For example, I tried:

     

    Code Snippet

    <object width="775px" height="500px" classid="clsid:000209FF-0000-0000-C000-000000000046">

      <param name="filename" value="sampleword.doc">

    </object>

     

    But this also does not work...

     

    Anyone have any ideas on this? Has anyone tried this before?

     

    Also, please, please, PLEASE DO NOT respond with a "Oh, why don't you just convert the Word doc's to HTML and paste the code into your page?"  WRONG!  I can't do this.  The users need to be able to edit the documents frequently and they do not know HTML or have access to an editor such as Dreamweaver. This is not a viable solution as I would then have to edit the HTML for them EVERY time they want to make a change. The content has to be available in the website, but the document itself needs to remain intact as a Word document so the users can edit it and make changes.

     

    Thanks in advance!

     

     

    Thursday, April 17, 2008 2:38 PM

All replies

  • No ideas on this? None at all??? I'm trying to figure this out soon so I can get it done already.

     

    Wednesday, April 23, 2008 4:10 PM
  • Hi mailman, i want to thank you for the example of OBJECT with a word doc that you posted here, it helped me resolve a similar problem.

    As for your problems, i found some solutions (tested in IE7)

     

    1) The content is not centered in the page with the rest of the content.

     

    to center it, put the Object tag inside a table and center it.

     

    2) The word document is clipped/ cut off.

     

    To avoid this you can set the height attribute of the Object tag to a number higher than the document real height (im thinking about using a ridiculous high number so it applies for all docs) and use the scroll workaround (see below).

     

    3) The object container is not scrollable.

     

    You can make it scrollable surrounding the object tag with a div like this:

     

    Code Snippet

    <table height="500px" width="100%" border="1" rules="all">

    <tr>

    <td align="center">

    <div id="div" style="height: 500px; width: 400px;overflow:scroll;">

    <object width="800" height="4000px" id="oWord" data="../Tests/Tareas.doc" classid="clsid:00020906-0000-0000-C000-000000000046">

    </object>

    </div>

    </td>

    </tr>

    </table>

     

     

     

     

    4) There are no other controls for the word document (not really necessary, but like a File menu with a Print option might be nice...

     

    Couldnt find a solution for this one.

     

    5) Unsure if this is cross-browser compatible or not. It's not really an issue for the environment I'm making this for (All IE6 running on Win2k...) but if I can get something to work, it might be useful for other webpages that I would want to be cross-browser compatible.

     

    I think it's not, like you i am in a fixed enviroment (WinXp/IE7) so i havent tested it in other enviroments, but doubt it is browser compatible.

     

    Tuesday, May 06, 2008 5:17 PM
  • Hi..

    did you get the solution for this problem.. i am also having same issue.. can you give some suggestion how did you implemented this

     

    Regards


    madhav
    Tuesday, October 11, 2011 11:39 AM
  • I'm actually looking for how to insert a html control that allows a user to type up a formatted word document such as this one. 

    This control lets me add bullets and some formatting. 

    I found something like this :http://www.edrawsoft.com/embed-office-aspnet.php which seems cool but is not free. 


    Friday, October 25, 2013 5:19 PM