![]() |
|
#1
|
|||
|
|||
|
Hi There
I am having trouble getting a macro to work in Word 2013 to un protect a password protected document, then re protect. I get the error Argument not optional and have no idea what this means. I eventually want the macro to unprotect the document, insert a row in a table then reprotect the document. Can someone please help. If ActiveDocument.ProtectionType <> wdNoProtection Then >> ActiveDocument.Unprotect Password:="password1" >> End If >> >> If ActiveDocument.ProtectionType = wdNoProtection Then >> ActiveDocument.Protect _ >> Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="password1" >> End If End Sub thanks so much Carol |
|
#2
|
||||
|
||||
|
Apart from the >> which should not be present, it works fine
Code:
Sub AddRow()
Const strPassWord As String = "password1"
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=strPassWord
End If
ActiveDocument.Tables(1).Rows.Add
'If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=strPassWord
'End If
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#3
|
|||
|
|||
|
Thank you so much for your assistance.
|
|
| Tags |
| macro, unprotect, word 2013 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Password protected file no longer offers password dialog on Open | htaylor | Word | 0 | 10-15-2013 12:35 PM |
| How to open a password-protected word document? | navalava | Word | 1 | 07-01-2012 12:15 PM |
Hyperlinks to password protected webpage
|
john_ | Outlook | 2 | 07-28-2011 01:43 AM |
Oops password protected word !!!
|
mistermouse | Word | 5 | 02-16-2011 01:56 PM |
| Password Protected Files | gurp99 | Word | 0 | 08-17-2010 03:30 PM |