Excel Excel VBA Password Protect Workbook

Joined
May 13, 2008
Messages
1
Reaction score
0
Hi All

I have code that copies selected sheets to a new workbook then emails that file to a specific address. I want to them password protect that workbook. but I cnnot specify the locaion it will be saved as it is attached to an email? I just need it saving with a password in the email for security purposes. please see below for the code and what I am trying to do.

<code>Sub Send1Sheet_ActiveWorkbook()

'ActiveSheet.Copy
Sheets(Array("1", "2", "3", "4", "5", "6")).Copy

For Each Worksheet In Sheets(Array("1", "2", "3", "4", "5", "6"))
Worksheet.Protect Password:="ORANGE"
Next Worksheet

ActiveWorkbook.SaveAs Filename:=LocalFileName, Password:="12"




'ActiveWorkbook.SaveAs Filename:="test.xls", FileFormat:= _
'xlNormal, Password:="1234", WriteResPassword:="x", ReadOnlyRecommended:= _
'True, CreateBackup:=False
Workbook.Protect Password:="test"


With ActiveWorkbook
.SendMail Recipients:="(e-mail address removed)", _
Subject:="Test"
.Close SaveChanges:=False
End With

End Sub</code>
 
I was looking for a way to open a password protected excel file via a macro. I got it from this enquiry of yours.
thanks mate~!
 
Back
Top