Consulting

Results 1 to 5 of 5

Thread: Help removing encryption from an excel template using VBA

  1. #1
    VBAX Newbie
    Joined
    May 2018
    Posts
    1
    Location

    Help removing encryption from an excel template using VBA

    Hi all,

    I've looked everywhere for an answer and the only thing I could find is removing the encryption because someone forgot the password or are trying to break the code to get into the file. I already know the password. I have an extremely complex excel 2010 template that I want to keep safe from those who don't know excel well enough to make it work. With this template, twice a month, I refresh the data and update the pivots and run a macro to save a copy of the splash page, or a dashboard for lack of a better term, as a separate file. However, when I run the macro, the saved copy also has the encryption. I need my macro that I run to remove the encryption so those who want to view the separate file with the copy of the splash page/dashboard can do so freely without the need of the password. Please let me know how to accomplish this, thanks.

    Yavihle

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    I don't think you can programmatically (i.e. VBA) remove the Project's password since that would that a security issue

    You'll probably have to remove the password from the copy manually


    Another approach might be to (instead of copying the protected workbook, have your macro .Add a new workbook and copy the appropriate worksheets into the new one
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by Yavhile View Post
    when I run the macro, the saved copy also has the encryption
    That suggests you need to review your Save As code and modify it to remove the password. For example:
    ActiveWorkbook.SaveAs Filename:="path & name", FileFormat:=xlWorkbookDefault, Password:=""
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by macropod View Post
    That suggests you need to review your Save As code and modify it to remove the password. For example:
    ActiveWorkbook.SaveAs Filename:="path & name", FileFormat:=xlWorkbookDefault, Password:=""
    I think that would also save the macros in the unprotected workbook, which possibly may not be desirable

    If the OP just wants the data viewable, then you'd have to .Add a new workbook and copy the appropriate worksheets into the new one

    Might even need to Copy/Paste Special Values also
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by Paul_Hossler View Post
    I think that would also save the macros in the unprotected workbook, which possibly may not be desirable
    The default save format is likely to be xlsx, which cannot contain macros. That said, one can be even more specific about the save format...
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Tags for this Thread

Posting Permissions

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