I'm trying to open a save Excel workbook while keeping a reference to the current workbook. The issue is that as soon as I open the saved workbook, the original throws an exception upon access. Here's a code snippet to demonstrate. I put this in an event handler for a [...] read more
If I have a reference to Worksheet and I close it's parent Workbook, the reference doesn't go away. But I can't figure out how I should check to make sure these sheets don't exist. Checking for null doesn't work. Example: Workbook book = Globals.ThisAddIn.Application.ActiveWorkbook; Worksheet sheet = (Worksheet)book.Worksheets[1]; // Get [...] read more
I've spent the past 3 hours trawling the web for answers to no avail, so I hope you can help me. I'm writing an application which automates Excel. The application has an option to "show/hide the excel sheet" so you can look at it, make any final changes and so [...] read more
In my application I want to be able to open an excel file that already exists, and add information to this file. I use the Microsoft Interop libraries. I have noticed that if you create a new spreadsheet using Add and then Saveas you can set the file to be [...] read more
I have a application where on Button click excel sheet will be opened and Data will be inserted into it. If i close excel sheet before inserting data folloeing exception occurs.. Exception from HRESULT: 0x800401A8 Is ther any way to handle this. My code is Excel.Application objApp = null; Excel._Workbook [...] read more
I'm trying to open an Excel Sheet, get the UsedRange and loop through it. This already worked once, but then I had the exception > COM object that has been separated from its underlying RCW cannot be used after using System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp); System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkBook); System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkSheet); Note that the exception kept coming up [...] read more
I'm writing a C# forms application to open an existing Excel workbook using the Excel Interop. Everything works fine. I can read and write fine. I do not save the workbook until the user close the C# application. The problem happens when my program is running and the user accidentally [...] read more
I need to populate a new spreadsheet for every 26 rows in a text file. I have created the initial spreadsheet but get the error System.Runtime.InteropServices.COMException:Exception from HRESULT:0x800401A8 when it starts the second file creation. read more
I want to pass an excel workbook/sheet as a reference between several functions in order to do different operations on it. I have been looking for hours and can't find out how to do this. Is this not common practice to have multiple functions work on an excel sheet in [...] read more
So I have created this program and it should reset the value and type of the cell to 1 and integer on startup. Then when the user wants to add a name, it should read the value and set it as AmountNumD (because it seems to detect it as a [...] read more
I'm trying split up the following code onto multiple threads (one for each sheet in the workbook). With over 400,000 rows to work on collectively, this would take quite some time on 1 thread, I'm hoping that if I split it, this will speed it up. It's been a while [...] read more
I have an Excel add-in firing an HRESULT 0x800401A8 error, when calling the getter of Worksheet.Parent. I would be glad if anyone could let me know what the error might be, but more importantly and more generally, I would like to know how I can understand these HResult codes? I [...] read more
I am trying to fill an excel sheet from SQL Server database and getting a message with code > HRESULT: 0x800401A8 Please assist me. Dim file As String = "C:\Techform.xlsx" Dim xlApp_2 As New Excel.Application xlApp_2.Visible = False xlApp_2.DisplayAlerts = False Dim oBook As Excel.Workbook oBook = xlApp_2.Workbooks.Open(file) Dim oSheet [...] read more