Macro Password

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

I have a big long macro that has "Unprotect sheet" and "Protect sheet"
features in it. When i was setting it up though, i chose not to enter in a
password. I know want to add a password instead of leaving the field blank.
Is there a way i can do this without redoing the whole long macro again??
 
Post the appropriate sections of your macro and someone will show you how to
modify it........

Vaya con Dios,
Chuck, CABGx3
 
I want to have the workbook protected to start with, but it will need to be
unprotected early on in the marcro for the macro to work. I will also need
for it to be protected again at the end.

Sub EMail()
'
' EmailCHECKORDER Macro
' Macro recorded
'
'Sub Mail_ActiveSheet_Outlook()
Calculate
Dim OutApp As Object
Dim OutMail As Object
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yyyy-mm-dd")
Application.ScreenUpdating = False
Sheets("Emailed").Visible = True
Sheets("Emailed").Select
Sheets("Emailed").Copy
ActiveSheet.Unprotect
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range("F2").Select
Application.CutCopyMode = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Set wb = ActiveWorkbook
With wb
.SaveAs "ASDF New Accounts.xls"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(o)
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "New Accounts Activity"
.Body = "When the file opens up, DO NOT UPDATE. Also, Please do
a 'Paste Special' and choose 'Values and Number Formats'"
.Attachments.Add wb.FullName
.Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Sheets("Emailed").Select
ActiveWindow.SelectedSheets.Visible = False
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Try this.......Replace your similar lines with these.......

ActiveSheet.Unprotect Password:=PW

ActiveSheet.Protect Password:=PW

Vaya con Dios,
Chuck, CABGx3
 

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

Back
Top