Pasting Word Document Content on Server Side

Last post 10-08-2010, 9:23 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  10-04-2010, 3:44 AM 64314

    Pasting Word Document Content on Server Side

    Hello,
     
    Since the LoadWord is not implemented yet, i thought of the following:
       - read the content of a word document using MsWord object on server side
       - copy the content of the file to clipboard
       - paste it to the Editor using the option PasteWord which cleans complex word formats
     
    I was able to write the code for the first two parts as follows

    'Read the DOC file
    Try

    Dim filePath As String = Server.MapPath("Forms\opr.doc")
    Dim wordApplication As Word.Application = New Word.Application
    Dim wordDoc As Word.Document = wordApplication.Documents.Open(filePath) wordApplication.ActiveDocument.Content.Copy()

    'Paste into Cute Editor

    wordDoc.Close()
    Catch ex As Exception
    End Try

     

    However how to write the part that pastes to the editor!?!? Any ideas out there?
    Thanks,

     
    Filed under: , ,
  •  10-08-2010, 9:23 PM 64360 in reply to 64314

    Re: Pasting Word Document Content on Server Side

    Hi Rantoun,
     
    CuteEditor support load the file in server side directly. Please test the this example , just put a rtf file "document.rtf" into the root of your site and test the page below.
     
    Note: For now, does not support load the "doc" file
    1. <%@ Page Language="VB" %>  
    2.   
    3. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5.   
    6. <script runat="server">  
    7.   
    8.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)  
    9.         editor1.LoadRTF("~/document.rtf")  
    10.     End Sub  
    11. </script>  
    12.   
    13. <html xmlns="http://www.w3.org/1999/xhtml">  
    14. <head runat="server">  
    15.     <title>Untitled Page</title>  
    16. </head>  
    17. <body>  
    18.     <form id="form1" runat="server">  
    19.         <div>  
    20.             <CE:Editor ID="editor1" runat="server">  
    21.             </CE:Editor>  
    22.         </div>  
    23.     </form>  
    24. </body>  
    25. </html> 
    Regards,
     
    Ken
View as RSS news feed in XML