Excel VBA Error with user access Permission.Add

Patrick D 21 Reputation points
2020-08-06T13:39:43.767+00:00

Hello,

I wrote an excel macro in VBA to split out a file by specific business segments. Each segment is restricted to users only affiliated with their specific segment. The macro uses the code below to add the email address of workers to the appropriate file breakout for their segment.

The macro was working as expected for a few months, now when I run the macro I receive an error; "Run-time error '-2147023727 (80070491)': Method 'Add' of object 'Permission' failed".

The code was never changed, concerned one of my settings might have been adjusted. Is there any guidance here that might help remedy this error? Also, is there a limit to the number of email address that can be added to a restricted workbook?

Existing VBA Code:

Dim irmPermission As Office.Permission

Dim objUserPerm As Office.UserPermission


    Set objUserPerm = ActiveWorkbook.Permission.Add( _
    "******@Company.com", _
     msoPermissionFullControl)
     Set objUserPerm = Nothing
Microsoft 365 and Office Excel For business Windows
{count} votes

Accepted answer
  1. Anonymous
    2020-08-06T13:50:58.267+00:00

    Excel development is not currently supported here on QnA. They're actively answering questions in dedicated forums here.
    https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-msoffice_custom
    https://social.msdn.microsoft.com/Forums/Lync/en-US/home?forum=exceldev

    --please don't forget to Accept as answer if the reply is helpful--


1 additional answer

Sort by: Most helpful
  1. Anonymous
    2020-08-06T15:52:21.35+00:00

    You're welcome.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.