ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   C# open workbook and suppress Read/Write dialog (https://www.excelbanter.com/excel-programming/374520-c-open-workbook-suppress-read-write-dialog.html)

Scott B[_2_]

C# open workbook and suppress Read/Write dialog
 
I'm using VS2005 C# to open a workbook invisible, import data from various
worksheets, process some data, then write back to the workbook. My problem is
that when I open the workbook in non-readonly mode, it errors when I try to
write to a cell. I made the workbook visible so I can see what's going on,
and it pops up a dialog with a button to Choose Read/Write for Editing. If I
click the button, my app works fine.
When I open the workbook I set the ReadOnly parm to false, the
IgnoreReadOnlyRecommended parm to true, and the Editable parm to true. I've
also set the Excel.DisplayAlerts to false:

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);

So what else do I need to do to get this to open as editable with no user
interaction (i.e., with the workbook not visible)?

--
Scott B

Scott B[_2_]

C# open workbook and suppress Read/Write dialog
 
Anybody have some input on this? I really need to fix it.
--
Scott B


"Scott B" wrote:

I'm using VS2005 C# to open a workbook invisible, import data from various
worksheets, process some data, then write back to the workbook. My problem is
that when I open the workbook in non-readonly mode, it errors when I try to
write to a cell. I made the workbook visible so I can see what's going on,
and it pops up a dialog with a button to Choose Read/Write for Editing. If I
click the button, my app works fine.
When I open the workbook I set the ReadOnly parm to false, the
IgnoreReadOnlyRecommended parm to true, and the Editable parm to true. I've
also set the Excel.DisplayAlerts to false:

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);

So what else do I need to do to get this to open as editable with no user
interaction (i.e., with the workbook not visible)?

--
Scott B



All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com