I have a VB.Net/C# application that programmatically:
- Creates an RTF document
- Open it in Microsoft Word
- Runs the Word macro that exists in the Word template using the following code:
The code:
Protected mobjWordApp As Word.Application = Nothing ' ' lots more code snipped for clarity ' With mobjWordApp.Dialogs.Item(Word.WdWordDialog.wdDialogToolsMacro) .Name = MacroName .Run = True .Execute() End With
It worked for a long time.
Now I have a new requirement; My application is only required to run SIGNED Word Macros.
This is easily done in the Word user interface as follows:
File > Options > Trust center > Macro Settings Select "Disable all macros except digitally signed macros"

Once this is established, if the person launching Word displays the Macros dialog box, any unsigned (or signed but unreliable) macros are not listed. This is all as I expected.
However, my VB.Net code that opens the Word application can work around this. When I run this code, it will run an unsigned macro:
With mobjWordApp.Dialogs.Item(Word.WdWordDialog.wdDialogToolsMacro) .Name = MacroName .Run = True .Execute() End With
I need to know:
Is there a way for my code to determine if a macro is signed (and trusted) before it runs?
Derek tomes
source share