I have .docx files in a sharepoint library. When I open file by the link, it opens in read-only mode
BUT
I can click "Enable edit", edit this document and save it to the sharepoint library.
Can I set only "read-only" permissions for this file?
How can I use DispEx for this?
I think you can set the library permissions to read only, so the user can pull a word doc from there, but not write to the library. As far as a word doc itself goes, I don't think you can keep that in read only. Once a user downloads a file, they can save it and edit it locally.. unless the word document is initially uploaded with some sort or protection. Case in point, open Word (2010+), choose File, and choose Info. There are various options in the Permissions section that should help you out.
Related
In our WPF application, we must create a Word document and open it automatically.
Today we ask the user to specify the file name and location BEFORE we create the document and them open the file using the Process.Start method.
Now, I want to create the Word document in memory stream, open it and eventually, when the user decides to save the document in Microsoft Word, he will have to specify the location and name. So I will not be using the SaveFileDialog in my app.
This is similar to when you start Microsoft Word. A default document is created and when you click save, you will guided to the "save as" function.
How can I do that?
I don't think you can do this purely on the memory stream. However, I would save the memory stream to a temporary file, by saving to the Temp folder or AppData\temp or something like that with a randomly-generated name, and then mark that file as read-only. Then open word on that file (with System.Diagnostics.Process or however you are doing it), and since it is read-only, it will ask the user to save changes when they exit.
Just programmatically create a new Word document using the standard Microsoft.Interop.Word .Net namespace:
How to: Programmatically Create New Documents
Note that you might need to install MS-Office to do this.
Note, too, that your application can display it's own "Save As" dialog (or, for that matter, could just use a hard-coded path) independent of Word. Your program chooses the path - and your program writes the Word document object if/when it's ready.
Finally, here's an alternative, open source library, DocX:
http://www.codeproject.com/Articles/660478/Csharp-Create-and-Manipulate-Word-Documents-Progra
How to: Open a word processing document from a stream (Open XML SDK)
ADDENDUM:
Thank you for your clarification:
You're using the OpenXML SDK (as an alternative to .Net Interop or DocX libraries I mentioned above). You've already created an in-memory document object.
Now you want the user to be able to open the document object in Word (presumably to review it), before saving it (to a filename of his/her own choosing).
You can't (easily) do that :)
One option, suggested by sovemp above:
a. OpenXML writes to a temp file (so it can be opened in Word)
b. Make the temp file read-only (to force the user to do an explicit "Save As")
c. Use .Net Process.Start() to invoke MSWord (specifying your temp file in your command line).
Another option might be to use a "Preview Handler":
http://www.codeproject.com/Articles/25465/Using-Vista-Preview-Handlers-in-a-WPF-Application
https://previewhandlers.codeplex.com/
Still another option might be to serve the memory stream in a web browser, using HTTP ContentType "application/msword" (for example)
Finally, if all you want is for the user to specify a filename (if "preview" isn't essential), you can always pop up your own "Save as" dialog and write document to disk directly from OpenXML.
I want to use "OLE automation" (or whatever it's called now) to generate a Word document.
I assume that it's possible to perform the following programmatically:
Set page size (height, width, margin vals)
Set font type/name, style, and size
Add page numbering
Add pages
Insert page breaks
What I'm not sure of is if I need to have MS Word on my system to do this (to have the necessary DLLs, perhaps)? I use Open Office (I like it, and it's free), but I reckon controlling the creation of docs programmatically is probably easier/better documented for MS Word than it is for Open Office and/or Libre Office - that's why I'm strongly considering making this "rendezvous with Redmond."
This question is tangentially related to this one
If Google Docs is a possibility here, I'd be willing to have a "meeting with Mountain View" but I know nothing about that file format or whether it can be "automated" etc.
I need to end up with something that I can either convert to a PDF file or a DOCX file. Open Office can open DOCX and convert files to PDF, but I don't know about Google Docs.
I've found https://docx.codeplex.com/ to be very useful in dynamically building docx documents.
Yes,
it is possible. Check this link: http://www.microsoft.com/en-us/download/details.aspx?id=30425
this is a library for open xml documents (*.docx, *.xlsx and powerpoint files)
yes you can Use Openxml , also with openXml you can create Excel Pdf and ...
Check This out
You can use this library to generate document by template:
https://github.com/StasClick/DocumentGenerator
'DocumentGenerator' can generate one leaflet, multiple leaflets in one document or registers.
Currently we have a .dot/.dat files which have template loaded and user when selects for a particular document we use the template generate a word document store it in temp location and display to user. When we are trying to access these documents we are getting an error as "Could not open macro storage.". I enabled macros on word document, and gave full read write permissions to user on template location on server. Nothing is fixing any ideas or pointers if anyone as came across this kind of similar issue. This is a windows desktop application.
I have some shared documents at my file server. I'd like to apply some sort of protection to these ms office documents. I want that put users in different groups and authorize them on files. Authorization means here that some users should not able to select a part of document, to copy the file. They should just able to view files as read only.
It is so workaround way doing it on office documents individually. Server permission system does not provide any selection protection etc.
Bottomline, I need something like Print Preview excluded editing and printing options.
Is there a way in order to do that programatically? It can be via C# or some other third party tools.
Thanks in advance.
I made it with WPF and XPS. Check this out for further information : http://www.codeproject.com/Articles/22849/Integrating-WPF-with-Windows-Forms
I'm using Interop to create a "custom word editor", basically I've incorporated MS Word on my application and I allow users to edit a document and insert custom fields from a predefined list.
I provide a "Preview" option to see how the document will appear when the data is added.
The users can start editing a template on my application, and at any time they can hit preview and the preview should appear with the latest changes.
I want the user to be able to preview the document without saving the changes, the problem is that when I invoke SaveAs() on the document (to create a temp file that I can use as the input for the preview generator), the editor opens the temp document.
Is there a way to save a copy of the document being edited but keep the original (open) document with its changes unsaved?
Thanks a lot
I know this can be done in pre-2007 Word, as described in this post.
Unfortunately, that solution does not work in Word 2007.
How about using a temp file from the get-go, and only saving to the "true" file when the user indicates that he or she is done?