Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27233

VS 2010 Unable to write to Excel , getting error Hresult 0X800A03EC

$
0
0
Hello
This is my first thread in VBforums. I am very new to VB. I am trying to write a text from 3 text boxes on a form to 3 columns in a excel. I am using below code but I am getting error as Hresult 0X800A03EC at code which i have written in BOLD :cry:

Dim ObjExcel As New Excel.Application()
ObjExcel.Visible = False

ObjExcel.Workbooks.Open("c:\test.xls")
Dim ObjWS As Excel.Worksheet = ObjExcel.Worksheets("Sheet1")


Dim iNextRow As Integer = ObjWS.UsedRange.End(Excel.XlDirection.xlDown).Row + 1

ObjWS.Cells(iNextRow, 1) = Textbox1.text
ObjWS.Cells(iNextRow, 2) = Textbox2.text
ObjWS.Cells(iNextRow, 3) = Textbox3.text


Dim objW As Excel.Workbook = ObjExcel.ActiveWorkbook
objW.Save()



ObjExcel.Quit()

Marshal.ReleaseComObject(ObjW)
Marshal.ReleaseComObject(ObjExcel)
ObjExcel = Nothing
ObjWS = Nothing
ObjW = Nothing
System.GC.Collect()
System.GC.Collect()

Can anyone help me on this issue ?

Viewing all articles
Browse latest Browse all 27233

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>