Save As w/ Password Protect

xMIKExSMITHx

New Member
Joined
Jul 11, 2014
Messages
38
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.
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

GR00007

Board Regular
Joined
Apr 22, 2015
Messages
184
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?
 

xMIKExSMITHx

New Member
Joined
Jul 11, 2014
Messages
38
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:

xMIKExSMITHx

New Member
Joined
Jul 11, 2014
Messages
38
I meant to reply directly to your post. Still getting used to the message boards....see my response below. :LOL:
 

GR00007

Board Regular
Joined
Apr 22, 2015
Messages
184
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,960
Messages
5,525,911
Members
409,671
Latest member
nasseralateek

This Week's Hot Topics

Top