hi there,
i have an application that opens an excel file and get the values to the mdf file in visual studio database file.

the code for opening the file is below

Microsoft.Office.Interop.Excel.ApplicationClass tt = new Microsoft.Office.Interop.Excel.ApplicationClass();
            String path = a;
            tt.Workbooks.Open(path,
                0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "",
                true, false, 0, true, false, false);

i have this code in a button event, when i click this a msg box appears saying "Modified by judith, Open as read only??"

y is this happeneing, how can i avoid it.

thanxxxx
in advance

Recommended Answers

All 6 Replies

Is the file that you are trying to open from the code already open in Excel application? I think Excel locks open files and only allows them to be opened in read-only mode while the first instance is open.

Is the file that you are trying to open from the code already open in Excel application? I think Excel locks open files and only allows them to be opened in read-only mode while the first instance is open.

hi

it isn't open in excel while i am running the application y is that happening??


thanxxxxxxxxx

I am not familiar with this interop library. Here is where I read the documentation:
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.open%28office.11%29.aspx

Maybe the file was saved with a ReadOnly recommendation.
Did you try changing the 7th parameter (IgnoreReadOnlyRecommended) to true?

Microsoft.Office.Interop.Excel.ApplicationClass tt =
    new Microsoft.Office.Interop.Excel.ApplicationClass();
String path = a;
tt.Workbooks.Open(
    path,                /*Filename*/
    0,                   /*UpdateLinks*/
    false,               /*ReadOnly*/
    5,                   /*Format*/
    "",                  /*Password*/
    "",                  /*WriteResPassword*/
    true, /*false,*/     /*IgnoreReadOnlyRecommended*/
    Microsoft.Office.Interop.Excel.XlPlatform.xlWindows,   /*Origin*/
    "",                  /*Delimiter*/
    true,                /*Editable*/
    false,               /*Notify*/
    0,                   /*Converter*/
    true,                /*AddToMru*/
    false,               /*Local*/
    false                /*CorruptLoad*/
);

I am not familiar with this interop library. Here is where I read the documentation:
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.open%28office.11%29.aspx

Maybe the file was saved with a ReadOnly recommendation.
Did you try changing the 7th parameter (IgnoreReadOnlyRecommended) to true?

Microsoft.Office.Interop.Excel.ApplicationClass tt =
    new Microsoft.Office.Interop.Excel.ApplicationClass();
String path = a;
tt.Workbooks.Open(
    path,                /*Filename*/
    0,                   /*UpdateLinks*/
    false,               /*ReadOnly*/
    5,                   /*Format*/
    "",                  /*Password*/
    "",                  /*WriteResPassword*/
    true, /*false,*/     /*IgnoreReadOnlyRecommended*/
    Microsoft.Office.Interop.Excel.XlPlatform.xlWindows,   /*Origin*/
    "",                  /*Delimiter*/
    true,                /*Editable*/
    false,               /*Notify*/
    0,                   /*Converter*/
    true,                /*AddToMru*/
    false,               /*Local*/
    false                /*CorruptLoad*/
);

hey,

i was like that the IgnoreReadOnlyRecommended parameter was set to true,
but the message appears

y is that,

thanx

bs

reReadOnlyRecommended parame

Run the app a couple of times, open task manager and look for the excel process. if there are many, then its an interop prob, you need to force a GC on it. First check that, and if that is the case, then i will provide you with the code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.