Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-07-2014, 06:32 PM
pooklet pooklet is offline Macro to Unprotect password protected document Windows 7 64bit Macro to Unprotect password protected document Office 2013
Novice
Macro to Unprotect password protected document
 
Join Date: Dec 2014
Location: Melbourne, Australia
Posts: 2
pooklet is on a distinguished road
Default Macro to Unprotect password protected document

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
Reply With Quote
  #2  
Old 12-07-2014, 10:41 PM
gmayor's Avatar
gmayor gmayor is offline Macro to Unprotect password protected document Windows 7 64bit Macro to Unprotect password protected document Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 12-08-2014, 01:32 AM
pooklet pooklet is offline Macro to Unprotect password protected document Windows 7 64bit Macro to Unprotect password protected document Office 2013
Novice
Macro to Unprotect password protected document
 
Join Date: Dec 2014
Location: Melbourne, Australia
Posts: 2
pooklet is on a distinguished road
Default

Thank you so much for your assistance.
Reply With Quote
Reply

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
Macro to Unprotect password protected document Hyperlinks to password protected webpage john_ Outlook 2 07-28-2011 01:43 AM
Macro to Unprotect password protected document 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:34 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft