PDA

View Full Version : [SOLVED] Overwrite write reserved file with updated copy (same name; also write reserved)



vanhunk
02-06-2014, 03:38 AM
Is it possible to use VBA to overwrite a file previously saved as read only with an updated copy (same name), also as read only? "Run-time error '1004': Operation failed. "\\mgadmdat\public\Reliability & Engineering Services\Workshop and Fabrication Service\Fabrication\ISO 9001\Contractors Score Card\Archive\Fabrication Contractor Score Card (2011 - 2012).xls' is write reserved." I.e. "Operation failed. 'FullFileName.xls' is write reserved." I get this error when I am trying to overwrite the existing file with the following code: (Note: The code must also work when there are no previously saved copy)
Dim NewBookName As String NewBookName = Range("FabConSCFFN").Value ActiveWorkbook.SaveAs FileName:=NewBookName, _ FileFormat:=xlNormal, _ PassWord:="", _ WriteResPassword:=WagWoord, _ ReadOnlyRecommended:=True, _ CreateBackup:=False I appreciate your time, Regards, vanhunk Also posted at the following due to user interface problems: http://www.excelforum.com/excel-programming-vba-macros/987270-overwrite-write-reserved-file-with-updated-copy-same-name-also-write-reserved.html#post3574499

vanhunk
02-06-2014, 02:31 PM
Solved by BrianMH (http://www.mrexcel.com/forum/members/brianmh.html):


Sub OpenReadOnlyFileWithPassword()

Workbooks.Open Filename:="ReadOnlyFile.xls", WriteResPassword:="Wagwoord", _
ReadOnly:=False, IgnoreReadOnlyRecommended:=True

End Sub

Thank you