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>
 
Joined
Aug 7, 2009
Messages
1
Reaction score
0
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~!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top