+ Reply to Thread
Results 1 to 5 of 5

VBA to password protect a newly created Excel file

  1. #1
    Forum Contributor
    Join Date
    08-08-2015
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    205

    VBA to password protect a newly created Excel file

    Hello, curious if this is an option. I have a file with 20 tabs that, using the below code, generates 20 separate files, one for each tab. Is it possible to add code so that each of those files are password protected automatically, so that I do not have to open each file, and save as with a password?

    Thanks so much for any assistance.
    Sheryl

    HTML Code: 

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to password protect a newly created Excel file

    Hi there,

    Try modifying your SaveAs statement as follows:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: VBA to password protect a newly created Excel file

    Hi Sheryl,

    It should be a simple case of recording the steps to lock & password protect one of the new files and then add that generated code into your existing macro. Said quickly that doesn't sound too bad although the devil is as always in the detail.

    I would have actually done it for you if you had posted an example of your spreadsheet as well as the code snippet in your post

    (I just saw Greg post and realised that I was looking at how to lock cells and protect the sheet rather than adding a simple password

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  4. #4
    Forum Contributor
    Join Date
    08-08-2015
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    205

    Re: VBA to password protect a newly created Excel file

    Ooooo that was easy, thank you!!!

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to password protect a newly created Excel file

    Hi again,

    Many thanks for your very prompt feedback and also for the Reputation increase - much appreciated!

    You're welcome - glad I was able to help.

    Best regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VB Code to password protect PDF File created
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2016, 08:43 PM
  2. [SOLVED] Sending an email of a newly created PDF file through VBA
    By Johnnyv015 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-12-2015, 07:15 PM
  3. [SOLVED] Newly created file not saving at the given location!
    By Sandr54 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-01-2014, 02:24 AM
  4. copying data from excel into a newly created xml file
    By m_Jawed in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2014, 10:08 AM
  5. Macro for copying specific data from excel files in a folder to a newly created excel file
    By Raju Radhakrishnan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-06-2012, 02:24 PM
  6. Protect a range in a newly created excel file
    By burugudug in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-16-2010, 06:00 PM
  7. Creating a file in a newly created folder.
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-12-2010, 03:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1