0

I would not ask this if I could find any related posts about this.
What I have:
1.) A workbook with multiple sheets with data in it (each sheet has specific column "Managers")
What I need:
1.) Create multiple Workbooks from original Workbook which will contain data only for specific manager.
2.) Create set of permissions for each new file so only developers (me, for example) and specific manager can access the file.
What I've done so far:
1.) I managed to create new files with .SaveAs method
2.) Now I have to Call Create after each .SaveAs and this part doesn't work

Sub Create()
    Dim ManagerPerm As Office.UserPermission
    Set ManagerPerm = ActiveWorkbook.Permission.Add( _
        "username@domain.loc", _
        msoPermissionRead + msoPermissionEdit)
    Set ManagerPerm = Nothing
End Sub

As it returns error on Set ManagerPerm = ... enter image description here

I've never tryed this before, thanks in advance for any advice.
P.S. Yes, I know I have to remove all permissions before that but for now I can't even add new.
P.P.S. Workbook Permissions in VBA Macros
Who am I? How to use Microsoft Office Permission/UserPermission
didn't help me out in this matter

Community
  • 1
  • 1
AntiDrondert
  • 1,128
  • 8
  • 21
  • Possible duplicate of [Workbook Permissions in VBA Macros](https://stackoverflow.com/questions/35550761/workbook-permissions-in-vba-macros) – Luuklag Aug 11 '17 at 08:05
  • @Luuklag Neither this question or question linked to it has a clear answer. Even more, in [Workbook Permissions in VBA Macros](https://stackoverflow.com/questions/35550761/workbook-permissions-in-vba-macros?noredirect=1&lq=1) his code should return an error "Type mismatch" not failed method of an object. – AntiDrondert Aug 11 '17 at 08:24
  • 1
    http://www.java2s.com/Code/VBA-Excel-Access-Word/Excel/ShowUserPermissions.htm – Luuklag Aug 11 '17 at 08:34
  • @Luuklag Feeling more stupid with each second passed. It returns "Method 'Item' of object 'Permission failed" on line `Set user = myPermission ("XX@YY.ZZZ")` – AntiDrondert Aug 11 '17 at 09:17

0 Answers0