Save a File with a Password Q
this example may be a little more than you were looking for as includes a
test on Path to detrmine if file has been previousley saved - it also shows
how to include password from a range value.
Hope useful
Sub SaveBook()
Dim Passwrd As Range
Dim FName As Variant
Dim FPath As String
'change sheet name & range as required
Set Passwrd = Worksheets("Sheet1").Range("A1")
Application.DisplayAlerts = False
With ThisWorkbook
FName = .Name
FPath = .Path
If FPath < "" Then
.SaveAs Filename:=FName, Password:=Passwrd.Value
Else
FName = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls")
If FName < False Then
.SaveAs Filename:=FName, Password:=Passwrd.Value
End If
End If
End With
Application.DisplayAlerts = True
End Sub
--
jb
"Seanie" wrote:
Is it possible to save via Code a file with a password that resides is
a cell within the workbook?
|