c# – Disable Excel Security Dialogs when using DsoFramer – Education Career Blog

I’m using the old DsoFramer control to embedded an instance of Excel in a form of mine. This has been working fine with Excel 2000, 2003 and 2007.

Come 2010 however I think its behaving slightly differently. I now get a prompt about macros, which then blocks my UI until the user shifts focus to the excel instance in the background and clicks ok.

alt text

I know that Microsoft don’t endorse using this control anymore, but unfortunately we’re not in a position to replace it yet. So what I’m looking for our ways to try and disable this dialog. I’ve tried using the MsoAutomationSecurity.msoAutomationSecurityForceDisable enum but this doesn’t seem to make any difference. If I open the file directly through code then its fine and doesn’t prompt, but the axFramer.Open() call always causes it to prompt. Does anyone know of a way round this?

Code to reproduce this issue in a simple WinForm app (you’ll need to substitute the file path to a file containing macros).

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Excel;
using System.Diagnostics;

namespace WindowsFormsApplication1
    public partial class Form1 : System.Windows.Forms.Form
    private AxDSOFramer.AxFramerControl axFramer;

    public Form1()
        // Kill any Excel processes first so they don't interfere with our tests


            string file = @"c:\temp\date_6490.xls";

            // Create a new Excel Application. For the purpose of the test lets ensure it's visible too.
            Application excelApp = new Application() { Visible = true, DisplayAlerts = false };

            // Set the Excel security to Forcefully disable all macros.
            excelApp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;

            // Open the file. This is because it needs to be open before trying with the DsoFramer
            // control. It also demonstrates that excel opens fine without prompting for any 
            // macro support.
            Workbook selectedBook = excelApp.Workbooks.Open(file);

            // Open the file in the framer. This will now prompt to enable macros.
            axFramer.Open(file, true, null, null, null);
        catch (Exception e)

    /// <summary>
    /// Creates a DsoFramer and adds to the form.
    /// </summary>
    private void CreateAndAddFramer()
        // Create an axFramer control
        this.axFramer = new AxDSOFramer.AxFramerControl();

        // Initialize the axFamer

        // Update the name of the framer (bug in framer)
        this.axFramer.Name = "framer_" + Guid.NewGuid().ToString();

        // Dock the framer and add to the form
        this.axFramer.Dock = System.Windows.Forms.DockStyle.Fill;

    /// <summary>
    /// Kills all excel processes.
    /// </summary>
    private static void KillExcelProcesses()
        // Kill all instances of Excel
        foreach (Process p in Process.GetProcessesByName("excel"))



The DsoFramer download was removed at the exact same time that the first beta of Office 2010 shipped. This is not a coincidence. OLE embedding is dead as a doornail, it has been for the past 8 years. You could try calling Microsoft Support but I’m pretty sure they’ll flip you the bird. You cannot keep your app in its present form and hope to continue future Office versions.

This answer was not meant to be helpful, merely reinforcing that you are spending your time and energy trying to solve the wrong problem.

Leave a Comment