S
Scott B
I'm using C# to open a spreadsheet invisibly, read some data from it, then
write back to it. The problem is that it it is not coming up editable - it
errors when I try to write to a cell. However, if I open the spreadsheet
visibly, after a number of seconds a dialog pops up "File xxx is now
available for editing. Choose Read-Write to open it for editing", and if you
click the Read-Write button, it works OK.
Here's my code for opening the spreadsheet. The comment is something I found
for the parameters C# needs (since it doesn't handle optional parameters like
VB).
So I'm setting ReadOnly = false, IgnoreReadOnlyRecommended = true, and
Editable = true.
What is wrong? Why does it take the user interaction to open it as
editable/writable? And since it takes about 12-14 seconds for that Read-Write
dialog to pop up, it's unacceptable.
/*
* Workbooks.Open(
[In] string Filename,
[In, Optional] object UpdateLinks,
[In, Optional] object ReadOnly,
[In, Optional] object Format,
[In, Optional] object Password,
[In, Optional] object WriteResPassword,
[In, Optional] object IgnoreReadOnlyRecommended,
[In, Optional] object Origin,
[In, Optional] object Delimiter,
[In, Optional] object Editable,
[In, Optional] object Notify,
[In, Optional] object Converter,
[In, Optional] object AddToMru,
[In, Optional] object Local,
[In, Optional] object CorruptLoad)
*/
Excel.Workbook obWb = obWorkBooks.Open(
filePath,
System.Type.Missing,
bReadOnly,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing,
true,
System.Type.Missing,
System.Type.Missing,
!bReadOnly,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing);
write back to it. The problem is that it it is not coming up editable - it
errors when I try to write to a cell. However, if I open the spreadsheet
visibly, after a number of seconds a dialog pops up "File xxx is now
available for editing. Choose Read-Write to open it for editing", and if you
click the Read-Write button, it works OK.
Here's my code for opening the spreadsheet. The comment is something I found
for the parameters C# needs (since it doesn't handle optional parameters like
VB).
So I'm setting ReadOnly = false, IgnoreReadOnlyRecommended = true, and
Editable = true.
What is wrong? Why does it take the user interaction to open it as
editable/writable? And since it takes about 12-14 seconds for that Read-Write
dialog to pop up, it's unacceptable.
/*
* Workbooks.Open(
[In] string Filename,
[In, Optional] object UpdateLinks,
[In, Optional] object ReadOnly,
[In, Optional] object Format,
[In, Optional] object Password,
[In, Optional] object WriteResPassword,
[In, Optional] object IgnoreReadOnlyRecommended,
[In, Optional] object Origin,
[In, Optional] object Delimiter,
[In, Optional] object Editable,
[In, Optional] object Notify,
[In, Optional] object Converter,
[In, Optional] object AddToMru,
[In, Optional] object Local,
[In, Optional] object CorruptLoad)
*/
Excel.Workbook obWb = obWorkBooks.Open(
filePath,
System.Type.Missing,
bReadOnly,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing,
true,
System.Type.Missing,
System.Type.Missing,
!bReadOnly,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing);