How do I automatically input password for excel sheet

ghrek

Active Member
Joined
Jul 29, 2005
Messages
317
Hi

I have a excel sheet that is password protected but when I come to print I have to unprotect and print and then reprotect.

Is there anyway I can set it up to automatically input password as dont want to give it out.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
10,646
You could use this macro to do what you want. Insert a button on your protected sheet and assign the macro to it. Change the password (in red) to suit your needs.
Rich (BB code):
Sub PrintSheet()
    With ActiveSheet
        .Unprotect Password:="YourPassword"
        .PrintOut
        .Protect Password:="YourPassword"
    End With
End Sub
To protect your macro so that nobody can see your password, you have to protect your VBA Project. Do the following:
-hold down the ALT key and press the F11 key to open the Visual Basic Editor
-click on 'Tools' on the top menu
-click 'VBAProject Properties'
-click the 'Protection' tab
-click the box to the left of 'Lock project for viewing' to put a check mark in it
-enter your password and then confirm it and click 'OK'
-close the VB Editor
-save your workbook as a macro-enabled file and close it
When you re-open the file, you will not be able to see the macro unless you enter the password. Keep in mind that this type of protection is not very strong and anyone who really wants to get at your macros can probably do it with a little research. I hope this helps.
 
Solution

Forum statistics

Threads
1,147,958
Messages
5,744,043
Members
423,841
Latest member
barren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top