View Single Post
  #1   Report Post  
dagarve dagarve is offline
Junior Member
 
Posts: 1
Default Office Macro security

I have a question regarding Macro security handling in Office (specifically in Word and Excel). We are writing Office add-ins that interacts with a Document Management System (DMS). I need to be able to predict whether Word (or Excel) is going to ask the user if wants to enable Macros. Sorry for the long post, but it takes a few lines to explain this. :-)

We have used the DocumentBeforeClose (for Word: Microsoft.Office.Interop.Word.ApplicationEvents4) event where we have written an event handler. Now, every time a user closes a document, given the document has been checked out from the DMS, we ask the user if he wants to check the document in again. This works perfect for most situations, except the following:

• IF the document contains macros AND the macro settings is set to “Disable all macros with notification” (Trust Senter | Macro settings) AND the document is not located in a “Trusted location”, THEN Word will ask the user if he wants to enable macros. If the user ignores this question and continues working with the document, this is still not a problem. However, if the user choses to “Enable macros”, Word closes the document and reopens it (executing macros if applicable).

This also fires the DocumentBeforeClose event, which eventually leads to displaying our question “The document is checked out to you, do you want to check in again?” which is of course inappropriate and not very elegant at this point, because the user is actually opening a document, not closing.

This is the reason why we need to be able to predict WHY Word is closing the document, is it because the user closed the document or is it because Word forced a document close to reopen it with macros enabled. So, if there is a way to predict whether the document is closed for immediate reopening (which is the case if the user confirm that he want to enable macros), we could omit our re-check-in question.

I’ve been looking into using the msoAtuomationSecurity enumerable, but it seems this is set to msoAutomationSecurityLow despite of the security settings in Word which is set to “Disable all macros with notification”.

I have not been able to actually see the connection between the Macro Setting in Word and the value of msoAtuomationSecurity. An alternative solution to the problem could be to detect the Macro Setting in the Trust Center (if possible) and from that decide what to do. But I have not found any way of detecting these settings. Are they stored in registry?

Anyone got a clue?

Thank's in advance

Last edited by dagarve : June 21st 12 at 11:36 AM