View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
dolores dolores is offline
external usenet poster
 
Posts: 12
Default Creating a Macro that saves over a protected spreadsheet.

Is there a way to create a macro that can save over a protected file.


I used the macro record tool that comes with excel, to record the save as
function, however the document I am trying to save over is a protected file,
so I keep getting an error. Is there some code that can be added to my macro
listed below so that I do not have to manually unprotect my file before I run
the macro?

Sub saveas()
'
' saveas Macro
' Macro recorded 9/30/2008 by dgomez
'
ChDir "F:\Illinois-Indy Sales"
ActiveWorkbook.saveas Filename:="F:\Illinois-Indy Sales\Bid
Register.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

when I run the macro I get the following error "Cannot access read-only
document "Bid Register.xls"