Retaining VBA Protection When Sheet is Exported

mwcalc

New Member
Joined
Feb 21, 2016
Messages
16
Hello all,

Normally I see people posting to find out how they can remove VB protection, I'm looking for the opposite. I have a workbook with multiple sheets, the work has VBA set to "Lock project to viewing", the sheets themselves are also protected to help stop accidental deletions. I have a macro that exports the final totals worksheet (only 1 worksheet, with all the macros for that sheet contained in the sheet module) to a new workbook. The sheet protection is remaining, but the VB Editor is no longer locked for viewing. How can I export the sheet & keep the VBE locked?

Thanks,
Michael
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Like I said. I'm not too familiar with the object model but, I did find a post from an experienced user on OzGrid that says:

Unfortunately, VBA does not expose the VBProject passwords in its object model. Consequently, the only way to achieve what you want is via a workaround.

Unprotecting VBA Project via VBA code to change code


SEE POST 4

Another workaround might be copying the entire workbook and then deleting the additional sheets that are no longer needed.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top