EDN Admin
Well-known member
Actully in to make document readonly we code like this. _appObject = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document _DocObj;
string file = @”c:UsersPublicPublic DocumentsWord12.docx”;
_DocObj = _appObject.Documents.Open(ref file, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
//protect
_appObject.ActiveDocument.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyReading, ref noReset, ref password, ref useIRM, ref enforceStyleLock);
But I want to make the Paragraph or range to readonlyforeach (Microsoft.Office.Interop.Word.Paragraph aPar in _appObject.ActiveDocument.Paragraphs)
{
Microsoft.Office.Interop.Word.Range parRng = aPar.Range;
string sText = parRng.Text;
// I want to make readonly here
}
_DocObj.SaveAs(FileName: TargetDir, FileFormat: WdSaveFormat.wdFormatDocumentDefault);
object saveChanges = WdSaveOptions.wdSaveChanges;
object originalFormat = WdOriginalFormat.wdOriginalDocumentFormat;
object routeDocument = true;
islockStatus = true;
var doc_close = (Microsoft.Office.Interop.Word._Document)_DocObj;
doc_close.Close(ref saveChanges, ref originalFormat, ref routeDocument);
While making the whole document readonly, We facing severe performance issues.
Hence the requirement is like that to make a portion of word document (especially HEADING or paragraph or alteast range) .
siva
View the full article
Microsoft.Office.Interop.Word.Document _DocObj;
string file = @”c:UsersPublicPublic DocumentsWord12.docx”;
_DocObj = _appObject.Documents.Open(ref file, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
//protect
_appObject.ActiveDocument.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyReading, ref noReset, ref password, ref useIRM, ref enforceStyleLock);
But I want to make the Paragraph or range to readonlyforeach (Microsoft.Office.Interop.Word.Paragraph aPar in _appObject.ActiveDocument.Paragraphs)
{
Microsoft.Office.Interop.Word.Range parRng = aPar.Range;
string sText = parRng.Text;
// I want to make readonly here
}
_DocObj.SaveAs(FileName: TargetDir, FileFormat: WdSaveFormat.wdFormatDocumentDefault);
object saveChanges = WdSaveOptions.wdSaveChanges;
object originalFormat = WdOriginalFormat.wdOriginalDocumentFormat;
object routeDocument = true;
islockStatus = true;
var doc_close = (Microsoft.Office.Interop.Word._Document)_DocObj;
doc_close.Close(ref saveChanges, ref originalFormat, ref routeDocument);
While making the whole document readonly, We facing severe performance issues.
Hence the requirement is like that to make a portion of word document (especially HEADING or paragraph or alteast range) .
siva
View the full article