• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1289
  • Last Modified:

How do I programmatically disable macros in Microsoft Project files using C#?

In SQL Server Integration Services (2008) I have a created a task script using C# that converts Microsoft Project (2010) MPP files to an ASCII text CSV format. The problem I have encountered is that because some of the files still have their macros enabled, the process stops and presents a window asking whether to "Enable" or "Disable" the file's macros. Because multiple files are being automatically processed, I need to set in the C# code a default of disabling all macros.
 
Does anybody know how to do this?
 
I tried the following, but couldn't get it to work because it would not recognize the "AutomationSecurity" item under Application.   It returns the message: 'System.Windows.Forms.Application' does not contain a definition for 'AutomationSecurity'.

 
Application.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;

Here are the references being applied at the top of the class file.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using Microsoft.Office.Core;
using MSProject = Microsoft.Office.Interop.MSProject;


Thanks.
0
COTraveler
Asked:
COTraveler
1 Solution
 
COTravelerAuthor Commented:
This issue has been resolved.  For some reason the same C# code when applied in a SSIS script task no longer prompts for the disabling of macros, relative to that in a Windows and console application.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now