ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro Password (https://www.excelbanter.com/excel-discussion-misc-queries/171361-macro-password.html)

Kevin

Macro Password
 
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??

CLR

Macro Password
 
Post the appropriate sections of your macro and someone will show you how to
modify it........

Vaya con Dios,
Chuck, CABGx3



"Kevin" wrote:

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??


Kevin

Macro Password
 
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 = "
.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

"CLR" wrote:

Post the appropriate sections of your macro and someone will show you how to
modify it........

Vaya con Dios,
Chuck, CABGx3



"Kevin" wrote:

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??


CLR

Macro Password
 
Try this.......Replace your similar lines with these.......

ActiveSheet.Unprotect Password:=PW

ActiveSheet.Protect Password:=PW

Vaya con Dios,
Chuck, CABGx3



"Kevin" wrote:

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 = "
.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

"CLR" wrote:

Post the appropriate sections of your macro and someone will show you how to
modify it........

Vaya con Dios,
Chuck, CABGx3



"Kevin" wrote:

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??



All times are GMT +1. The time now is 09:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com