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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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. :LOL:
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,214,386
Messages
6,119,212
Members
448,874
Latest member
b1step2far

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