Microsoft Office documents, im my case: PowerPoint presentations, can have restricted permissions. How can I find out, programmatically, which permissions my code has on a given document?
All I can find on MSDN on this topic is this: http://msdn.microsoft.com/en-us/library/aa432118.aspx
If I run the attached code, I get a list of users that have permissions on the given document. The "Permission" is a bitmap the definition for which I found in Microsoft's public COM header files (see next to code).
Still, this does not tell me which particular permissions my code has. If I only knew who I am (in terms of a UserPermission.UserId), I could look up my permissions in the Permission object. But I cannot find that bit of information. What am I missing?
There are known ways to obtain the Windows user name (the login name for the current user on that Windows machine). Unfortunately, this is not the user id that is checked against when PowerPoint decides which permissions I have on the document. To emphasize: PowerPoint provides a UI that lets me change "who I am" at run time. Obviously, this does not change the login use name (i.e., the name returned by ADVAPI). The user names PowerPoint is referring to, are identified/authorized via Microsoft's Passport.
Thanks in advance!
Dim perm As Office.Permission
Set perm = ActivePresentation.Permission
Dim uperm As Office.UserPermission
For Each uperm In perm
Debug.Print uperm.UserId & ", " & uperm.Permission
msoPermissionView = 1,
msoPermissionRead = 1,
msoPermissionEdit = 2,
msoPermissionSave = 4,
msoPermissionExtract = 8,
msoPermissionChange = 15,
msoPermissionPrint = 16,
msoPermissionObjModel = 32,
msoPermissionFullControl = 64,
msoPermissionAllCommon = 127