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
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

mwcalc

New Member
Joined
Feb 21, 2016
Messages
16
Matt -

Thanks, although I'd like to use a non-SendKeys option if there is one.
 

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,456
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:

Watch MrExcel Video

Forum statistics

Threads
1,123,304
Messages
5,600,861
Members
414,408
Latest member
macroSmith

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
Top