+ Reply to Thread
Results 1 to 4 of 4

To password protect the Workbook which is saved as a separate workbook from the main Data

  1. #1
    Registered User
    Join Date
    07-13-2013
    Location
    United Arab Emirates
    MS-Off Ver
    Excel 2007
    Posts
    8

    Thumbs up To password protect the Workbook which is saved as a separate workbook from the main Data

    Hi there,

    I have a master workbook on which a sheet "DailyAvg" is used to compile data from different sheets and then i save only this sheet as a separate Workbook with a UDF name. Basically i wanted to PW protect the newly saved Workbook. I have the below code which isn't seems to be working; Appreciate if someone can some help me to find a solution?

    Sub Save_data()
    '
    ' Save_data
    '

    '
    Dim ws As String
    Dim wc As String

    ws = ActiveWorkbook.Name

    SAVE_NAME = Range("B29")
    SAVE_MTH = Range("B28")
    SAVE_ROOT = Range("B27")

    Sheets(Array("DailyAvg")).Select
    Sheets("DailyAvg").Activate
    Sheets(Array("DailyAvg")).Copy
    Range("A1").Select

    ActiveWorkbook.SaveAs Filename:=SAVE_PATH & "\" & SAVE_FLDR & "\" & SAVE_NAME & ".xlsx"

    ActiveWorkbook.Protect Password:="password", Structure:=True, Windows:=True

    ActiveWindow.Close
    Windows(ws).Activate
    Sheets("Functions").Select
    ActiveWorkbook.Save

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: To password protect the Workbook which is saved as a separate workbook from the main D

    Unfortunately your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    07-13-2013
    Location
    United Arab Emirates
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: To password protect the Workbook which is saved as a separate workbook from the main D

    Hi there,

    I have a master workbook on which a sheet "DailyAvg" is used to compile data from different sheets and then i save only this sheet as a separate Workbook with a UDF name. Basically i wanted to PW protect the newly saved Workbook. I have the below code which isn't seems to be working; Appreciate if someone can some help me to find a solution?

    Sub Save_data()
    '
    ' Save_data
    '

    '
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    [/CODE]
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    [/CODE]
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: To password protect the Workbook which is saved as a separate workbook from the main D

    hi,
    try to modify yr code like this

    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button). The result will appear like this in the post window:

    Please Login or Register  to view this content.
    ... and appear like this when posted:

    Select Code copy to clipboard
    your code here ...
    and here ...
    and here
    You can also type the code tags in manually if you prefer. For more information about these and other tags, click here.

    Richard gave you the link, please read the forum rules!
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

+ 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. Generate separate workbooks from main Workbook
    By robbie58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2012, 05:08 PM
  2. Replies: 1
    Last Post: 04-12-2012, 03:42 AM
  3. Replies: 5
    Last Post: 09-30-2008, 06:38 AM
  4. Replies: 3
    Last Post: 09-30-2008, 04:58 AM
  5. Replies: 2
    Last Post: 07-16-2005, 11:05 AM

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