Public/PSWordRestrictions.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
function Add-WordProtection { [CmdletBinding()] param ( [parameter(ValueFromPipelineByPropertyName, ValueFromPipeline)][Xceed.Words.NET.Container]$WordDocument, [EditRestrictions] $EditRestrictions, [string] $Password ) if ($Password -eq $null) { $WordDocument.AddProtection($EditRestrictions) } else { $WordDocument.AddPasswordProtection($EditRestrictions, $Password) } } <# /// <summary> /// Returns true if any editing restrictions are imposed on this document. /// </summary> /// <example> /// <code> /// // Create a new document. /// using (DocX document = DocX.Create(@"Test.docx")) /// { /// if(document.isProtected) /// Console.WriteLine("Protected"); /// else /// Console.WriteLine("Not protected"); /// /// // Save the document. /// document.Save(); /// } /// </code> /// </example> /// <seealso cref="AddProtection(EditRestrictions)"/> /// <seealso cref="RemoveProtection"/> /// <seealso cref="GetProtectionType"/> #> |