Run MS Word Client Side from ASP.NET web site

Last post 05-13-2008 3:18 PM by Mikesdotnetting. 1 replies.

Sort Posts:

  • Run MS Word Client Side from ASP.NET web site

    05-13-2008, 2:52 PM
    • Member
      point Member
    • ski
    • Member since 05-13-2008, 6:28 PM
    • Posts 1

    Does anyone know how to write an ASP.NET/VB.NET web site that opens MS Word on the client's machine?  In the ASP.NET web application that I'm writing, the user selects a Word document from a listbox.  The user clicks a button to open the selected document and at the same time, special text strings are substituted into the Word document.  Here is code that launches MS Word on the server but I need to launch Word on the client machine.

            Dim myWordApp As Microsoft.Office.Interop.Word.Application = New Microsoft.Office.Interop.Word.Application
            Dim myWordDoc As Microsoft.Office.Interop.Word.Document = New Microsoft.Office.Interop.Word.Document
            Dim strDocToOpen As String = "\\sharefolder.mycompany.com\data\mydocument.doc"

            myWordApp.Visible = True

            myWordDoc = myWordApp.Documents.Add(strDocToOpen)

            myWordDoc.Content.Find.Execute(FindText:="@ANYSTRING", ReplaceWith:="NEWSTRING", Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll)

     This is code that's in WEB.CONFIG (for using Interop):

    <system.web><compilation defaultLanguage="vb" debug="true" explicit="true"><assemblies><add assembly="Microsoft.Office.Interop.Word, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"/></assemblies></compilation>

     Tks!

  • Re: Run MS Word Client Side from ASP.NET web site

    05-13-2008, 3:18 PM
    Answer

    Basically, you cannot do this with ASP.NET (because it only ever runs on the web server).  You would have to develop some kind of client-side browser control, such as an ActiveX that the user agrees to download and install.  That's well outside of the scope of these forums, but here's an article that will give you a start: http://msdn.microsoft.com/en-us/library/aa752037(VS.85).aspx

     

     

    Regards Mike
    [MVP - ASP/ASP.NET]
    My site
    What ASP.NET can and can't do
Page 1 of 1 (2 items)