Save As w/ Password Protect

xMIKExSMITHx

New Member
Joined
Jul 11, 2014
Messages
45
I have a few custom add-ins using various coding for specific work related tasks. At work, we password protect all our files. I am wondering if there is a specific code that I can add to my custom add-ins sheet that I would click and it would automatically do a Save As with a specified pw I set in the coding without having to go through the actual save as screen and general options setting.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Here's the syntax for save as:
https://docs.microsoft.com/en-us/office/vba/api/excel.workbook.saveas

Besides password, you also add WriteResPassword which will allow the workbook to open without a password, but only in read only mode.
To avoid the 'are you sure' prompts change display alerts
Code:
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:=vDir & vSaveName, _
        FileFormat:=version, Password:="whatever", WriteResPassword:="if-needed", _
        ReadOnlyRecommended:=False, CreateBackup:=False
    Application.DisplayAlerts = True
Caution: are you sure your macro is in a completely safe place where only authorized people can access the code?
 
Upvote 0
Hi GR,

Much obliged for the help. To answer your question, my add ins are on my work laptop on the desktop. Only I have access to and use them to make me work more efficient. They are all tailored to my specific roles like formatting a specific report I do and a few other ones. My main goal for this was to shave off the crucial time wasted on the mundane Save As--->General Options--->Type PW twice thing. Precious time being wasted when all my files need to be PW protected. Haha.
 
Last edited:
Upvote 0
I meant to reply directly to your post. Still getting used to the message boards....see my response below. :laugh:
No prob - I'm getting used to 'em as well - when I first saw 'Reply with quote' I had the thought it was giving the amount needed to do consulting stuff.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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
Back
Top