good-E
good-E

Reputation: 11

ReportINI.xls message when create new Excel.Workbook with Microsoft.Office.Interop.Excel in C#

I've a problem with Microsoft.Office.Interop.Excel in c#.

When I create a new Excel.Workbook:

Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"D:\...\...");

appears the follow message from excel:

Unable to locate ReportINI sheet. Please make sure, ReportINI.xls is in the -xlstart- subdirectory of the -office- program.

I've already tried to disable excel messages or disable the macros inside the excel sheet, but I can't found a solution...

Ps. I use Visual Studio 2010 and Office 2007. Of course, I'm new with C#, Visual Studio and Microsoft environment in general.

Someone know how can I solve this problem?

Thanks!

Upvotes: 1

Views: 1499

Answers (2)

HackSlash
HackSlash

Reputation: 5813

The reason you are seeing this is that you are opening a Calypso report that depends upon helper functions found in the ReportINI.xls file. If you are attempting to work with the Calypso automated report generator then you will need to find that file and open it first, before you open the report.

If you don't want to use the Calypso automatic report generator features then you should strip all the VBA code from the Calypso report file you are modifying. It's got some functions that run on open that point to the ReportINI.xls file.

Or just suppress the macros that run on open like this:

Excel.Application xlApp = new Excel.Application();
xlApp.EnableEvents = False
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"D:\...\...");
xlApp.EnableEvents = True

(Disabling the events during open will suppress the Workbook_Open event)

Upvotes: 0

kozmikadam
kozmikadam

Reputation: 1

The reason could be directly your excel files macros. Do you get same error when you open your excel file manually and release macros ?

I suggest disable macros with c# code in your project. Try this one :

Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();

//On here we disabled all macros
excelApp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;

Upvotes: 0

Related Questions