Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Open a word document from a webpage

Posted on 2013-11-27
2
Medium Priority
?
510 Views
Last Modified: 2013-12-16
I'm using asp.net in Visual Studios 2010 with vb.net code behind my webpage.  I have code to open a word document (.docm) when the user clicks the submit button.  I then update/populate the word document and save it to a shared drive location.  In testing the code works and on my development site it seemed to work.  The word document opens on the server side.

However, I want the document to open on the client side and not the server side so the user can see it.  Is there away to do that?

 Dim oWord As Word.Application
        Dim oDoc As Word.Document
        Dim oTable As Word.Table
        Dim keys(1) As System.Data.DataColumn
        Dim nRows As Integer
        Dim nCols As Integer

        keys(0) = detailTable.Columns("ROW_NO")


        detailTable.PrimaryKey = keys

        'Dim oChkBox As Word.CheckBox

        'Start Word and open the document template.
        oWord = CreateObject("Word.Application")
        oWord.Visible = False

        oDoc = oWord.Documents.Add(GetSafetyInspTemplate())  
       'GetSafetyInspTemplate() 'retunrs the word document with full path and  filename

        oTable = oDoc.Tables(3)
          ....
          'code to populate  the document
          ....
       
       oDoc.Close()
       oWord.Quit()
0
Comment
Question by:bkrbbnsEE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39683628
The inherent problem with COM is that it is single-threaded, while ASP.NET is multi-threaded.  Using the interop library is usually frought with problems.

Some alternatives include purchasing software, like Aspose or GemBox, or using Open XML.

Aspose.Words for .NET
http://www.aspose.com/.net/word-component.aspx

GemBox.Document
http://www.gemboxsoftware.com/document/overview

C#: Create and Manipulate Word Documents Programmatically Using DocX
http://www.codeproject.com/Articles/660478/Csharp-Create-and-Manipulate-Word-Documents-Progra
0
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 1500 total points
ID: 39689409
hi..
Try this Code...
FileInfo file = new FileInfo("Your FilePath");

Response.ClearContent();

Response.AddHeader("Content-Disposition", "inline;filename=" + file.Name);

Respone.AddHeader("Content-Length", file.Length.ToString());

Response.ContentType = "application/msword";

Reponse.TransmitFile(file.FullName);

Response.End();
0

Featured Post

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question