Unprotect sheet when printing

G

Guest

Have the below code to print a sheet, increment a invoice number and remove
protection from sheet, at the moment the passowrd is nothing I nee to change
this to qwert and edit the formula to up protect sheet on print and re
protect it after the incrementing of the invoice number. Any help would be
appreaciated.

Sub dayprint()
'
' dayprint Macro
'
'

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheet13.Unprotect
'Increment the invoice number
[e3] = [e3] + 1
Sheet13.Protect

' Save Macro
' Macro recorded 19/08/2005
'
'
ActiveWorkbook.Save
End Sub
 
N

Norman Jones

Hi BBC1,

Try something like:

Sub dayprint()
Const PWORD As String = "qwert"

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
With ThisWorkbook.Sheets("Sheet13")
.Unprotect Password:=PWORD
'Increment the invoice number
With .Range("E3")
.Value = .Value + 1
End With
.Protect Password:=PWORD
End With

ActiveWorkbook.Save
End Sub
 
G

Guest

Thankyou works great.

Norman Jones said:
Hi BBC1,

Try something like:

Sub dayprint()
Const PWORD As String = "qwert"

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
With ThisWorkbook.Sheets("Sheet13")
.Unprotect Password:=PWORD
'Increment the invoice number
With .Range("E3")
.Value = .Value + 1
End With
.Protect Password:=PWORD
End With

ActiveWorkbook.Save
End Sub


---
Regards,
Norman



bbc1 said:
Have the below code to print a sheet, increment a invoice number and
remove
protection from sheet, at the moment the passowrd is nothing I nee to
change
this to qwert and edit the formula to up protect sheet on print and re
protect it after the incrementing of the invoice number. Any help would be
appreaciated.

Sub dayprint()
'
' dayprint Macro
'
'

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheet13.Unprotect
'Increment the invoice number
[e3] = [e3] + 1
Sheet13.Protect

' Save Macro
' Macro recorded 19/08/2005
'
'
ActiveWorkbook.Save
End Sub
 

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

Top