PDA

View Full Version : Help removing encryption from an excel template using VBA



Yavhile
05-08-2018, 03:33 PM
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

Paul_Hossler
05-08-2018, 04:28 PM
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

macropod
05-08-2018, 09:40 PM
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:=""

Paul_Hossler
05-09-2018, 10:44 AM
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

macropod
05-09-2018, 02:24 PM
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...