Macro to unshare workbook and share it again with tracking changes

kubabocz

New Member
Joined
Oct 28, 2015
Messages
36
Hi guys,

I have one big macro in my file which does a lot of things but I have one problem now.
I have recently added part which should go to different spreadsheet, unhide some sheets, copy data and paste to the previous file.
The issue I have is that I always get an error as the file with the data is protected with "Protect and share workbook" option. And as it is shared like that I can not unprotect workbook and unhide the sheets.

Is there a way for macro to
1. Remove the file from shared use (with password stored in the code).
2. Do all the other stuff (I can do it myself)
3. Share the file with tracking and protect with password stored in the code.

My code looks like that:

Code:
 ' Cap 3
                    ActiveWorkbook.Unprotect "planning"
                    Windows("CAP 3.xlsm").Activate
                    Sheets("8 projects").Visible = True
                    Sheets("8 projects").Select
                    Range("A2:E49").Select
                    Selection.Copy
                    Windows("Reporting file - Central Product.xlsm").Activate
                    Range("A2:E49").Select
                    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                        :=False, Transpose:=False
                    Windows("CAP 3.xlsm").Activate
                    Sheets("8 projects").Visible = False
                    ActiveWorkbook.Protect "planning", Structure:=True, Windows:=False
                    Windows("Reporting file - Central Product.xlsm").Activate
                    Range("B2").Select

Thank you
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,215,362
Messages
6,124,502
Members
449,166
Latest member
hokjock

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