Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

how to save MS Word document allocated in memory of web server to client machine

I load a MS Word file into memory server side of asp.net page, modify it there. I want to know how to save it to client machine?
0
AlexKostrub
Asked:
AlexKostrub
  • 5
  • 4
  • 2
1 Solution
 
Xper4netCommented:
You have to save it on server side, into a temporary folder, and then propose the client to download it. Once done, you can remove it from server.
0
 
BardobraveCommented:
For obvious security reasons you cannot directly save a file in a client computer through a web application. What you can do is to stream the file data to the browser, wich will open the document with it's associated application.

Then users can decide if they save it to disk or not.
0
 
AlexKostrubAuthor Commented:
To Bardobrave: I think it is possible to save file to client machine with SaveAs Dialog. How it can be implemented. And how to stream MS Word document if I have variable of type Microsoft.Office.Interop.Word.Document , let's say WordDoc, that contains all data I need to save?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
BardobraveCommented:
Well... if you execute from your server code (where your word interop object is created) a piece of code to invoke "Save As" dialog, you'll be probably opening that dialog "on the server"... but I'm not very sure...

Msdn documentation also don't throws so much light about that, but you can try it and see what happens.
http://msdn.microsoft.com/en-en/library/63w57f4b%28v=VS.80%29.aspx



0
 
Xper4netCommented:
If you succeed to invoke a "save as" dialog on client side, I'll eat my hat ;-)
Seriously, you waste your time. You have to pass by a temporary file. Solution from Bardobrave can do the job too, but the use case is slightly different, and it needs Word installed on client side.
0
 
AlexKostrubAuthor Commented:
To Bardobrave: I mean activate SaveAs dialog on client machine using Response object but I still don't know how to write Microsoft.Office.Interop.Word.Document variable into it.
0
 
AlexKostrubAuthor Commented:
That is why I am looking for a way to write data stored in designated variable  to Response stream. Anyone knows how to do this?
0
 
BardobraveCommented:
Take a look at this thread.

http://forums.asp.net/t/1178233.aspx

Maybe tomorrow I have more time to explain it more deeply or put some code example.
0
 
AlexKostrubAuthor Commented:
Bardobrave, I am waiting for your explanation or/and code example
0
 
BardobraveCommented:
Here there's a great explanation of working with word interop. What you need to do is to open the document on client machine, once done is all to the user to decide if he saves it to disk or not.

http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx

I hope it helps.
0
 
AlexKostrubAuthor Commented:
I asked slightly different thing but satisfied with an answer.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now