Savecopyas without password

  • Thread starter Thread starter Ray Clark
  • Start date Start date
R

Ray Clark

I have an Excel workbook which requires a password to open. I need to
savecopyas but when opening the copy (which is read only) not require a
password.
 
I have an Excel workbook which requires a password to open.  I need to
savecopyas but when opening the copy (which is read only) not require a
password.

When you close the copy it wil ask for a password. Just skip through
with no entry and there wil be no password.affixed and henc none
required to reopen THAT "save as".

ed
 
If you don't care about losing the original workbook's password or know the
password to reapply it, you can use code like:

Option Explicit
Sub testme()

Dim CurWkbk As Workbook
Dim myFileName As String
Dim PWD As String

myFileName = "C:\book2222.xls"
PWD = "a"

Set CurWkbk = ActiveWorkbook

With CurWkbk
'remove the password to open
.Password = ""

'do the savecopyas
.SaveCopyAs Filename:=myFileName

'reapply the password
.Password = PWD

End With

End Sub
 
Dave,

Tried adding some extra code to remove the password prior to saving the copy
but when opening it still has the password.
This is the coding I have been using........
Private Sub Back_Up_Button_Click()
RQ1 = MsgBox("Save Maintenance Day Roster?", vbYesNo, "SAVE")
If RQ1 = vbYes Then
ActiveWorkbook.Save
With ActiveWorkbook
.Password = ""
End With
RQ2 = MsgBox("Save Copy for Viewing?", vbYesNo, "SAVE COPY")
If RQ2 = vbYes Then
RQ3 = MsgBox("Copy saved as 'Maint Day Roster for Viewing' and
Closed", vbOKOnly, "SAVE CLOSE Copy")
SetAttr "N:\MaintCo-ord\Mech\Maint Day Roster for Viewing.xls",
vbNormal
ActiveWorkbook.SaveCopyAs "N:\MaintCo-ord\Mech\Maint Day Roster
for Viewing.xls"
Workbooks.Open Filename:="N:\MaintCo-ord\Mech\Maint Day Roster
for Viewing.xls", _
UpdateLinks:=0
ActiveSheet.Shapes("Back_Up_Button").Select
Selection.Cut
ActiveWorkbook.Save
ActiveWorkbook.Close
SetAttr "N:\MaintCo-ord\Mech\Maint Day Roster for Viewing.xls",
vbReadOnly
ElseIf RQ2 = vbNo Then
RQ2A = MsgBox("Close Maint Day Roster?", vbYesNo, "CLOSE")
If RQ2A = vbYes Then
ActiveWorkbook.Close
End If
End If
RQ4 = MsgBox("CLOSE File?", vbYesNo, "CLOSE FILE")
If RQ4 = vbYes Then
ActiveWorkbook.Close
End If
ElseIf RQ1 = vbNo Then
RQ1A = MsgBox("Close File No Save", vbYesNo, "CLOSE FILE DON'T SAVE")
If RQ1A = vbYes Then
ActiveWorkbook.Close
End If
End If
End Sub

Any suggestions.
Thanks Ray
 
Dave,

When it gets to opening the copy to remove the button it requests the
password to open.

Ray
 
What happened when you ran the small version of the macro and then opened the
workbook manually?

Wasn't the password to open prompt gone?

Ray said:
No Dave did not work
Ray
 
Dave,

I appreciate all your help but may have found a way around this problem.

Ray
 
Back
Top