Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically determine Macro Security Level

Status
Not open for further replies.

jgillin

Programmer
Oct 22, 2003
82
US
Hi,
I'm trying to determine what the user's Macro Security Level is (ie, at runtime). Note that I'm not trying to set it, and I know that can't be done through code. The code is for a PowerPoint project, and I've looked through the PowerPoint object model, but wasn't able to find any property to access the security level.

You may be thinking "Why would he need that? The user will get a Macro warning and if they accept it, then the code will run." While that is true, there's another piece to this.

Here's the specifics:
In our case, we have a PowerPoint addin (PPA) that opens an external PPT file that also has some VBA code in it. If the user's Macro Security Level is set at "medium" everything works fine (they do get a second Macro warning when the other file is accessed from within the vba code, however that's not a problem). The main problem is that if their Macro Security Level is set to "high", then things start to fail. Variables get reset, and odd things happen. We're not 100% sure of the underlying reasons it works with "medium" and not "high" (since if they accept the Macro warning, then it should work), but anyhow, that's what happens.
Thanks for any thoughts or suggestions.
Jeff
 
Note: I forgot mention why we need to access their security level. The reason is that if their security level is set to high, we don't want to allow the Macro to run, but rather display a message saying that they'll need to lower their security level to "medium" in order for the addin to work properly.
 
If PP application opens another PP application, the security level is always low. In office xp it is possible to hihger it by setting Application.AutomationSecurity.
There is no way to get security setting directly via Application property. You can rearrange the way application works: move whole code to add-in, try to display menu slide using macros etc.

combo
 
Thanks for the reply.
The possibility of moving the functionality completely into the PPA won't work in our particular case. I won't go into all the details, but it has to do with adding ShockwaveFlash objects programmatically.
What you mentioned would be the desired functionality, but that option has been throughly attempted by several programmers). The problem has to do with query string parameters getting passed to the flash get lost when done within the PPA (even called Microsoft about this issue).
I have been looking into the Application.AutomationSecurity over the past week, and it doesn't seem to work as documentation suggests. We're using PowerPoint 2003, so it should work (but it doesn't). Documentation on Microsoft's site suggestions that if you set the level to msoAutomationSecurityLow, which is the default anyhow, then you shouldn't get a second popup when loading external files that contain vba code since Macros are enabled during the acceptance of the first popup (but we do). I'm not sure why. I've even tried setting Application.AutomationSecurity to msoAutomationSecurityLow just before accessing the file (as well as after), but it doesn't seem to affect anything. Any ideas why this is still giving a Macro security popup when loading the external PPT file?
 
Jeff,

I hate to say it, but your best recourse may be to obtain a digital signature and sign the external ppt file. This would allow the vba code in the external ppt file to run regardless of the end user's security setting.


Regards,
Mike
 
Mike,
I thought that a digital signature might be necessary, and I appreciate your suggestions on this.
Thanks,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top