I'm attempting to copy data from excel workbook to another, but I'm getting at HRESULT: 0x800A03EC when trying to copy.
I've have read in detail and tried everything in an earlier post HRESULT: 0x800A03EC on Worksheet.range
Everything except changing the properties on the excel applications in the DCOM config (I didn't see the excel application)
Below is the code and error is happening in the bold.
Imports Excel = Microsoft.Office.Interop.Excel
Dim xlApp As Excel.Application = Nothing
Dim newxlApp As Excel.Application = Nothing
Dim xlWorkBooks As Excel.Workbooks = Nothing
Dim xlWorkBook As Excel.Workbook = Nothing
Dim xlWorkSheet As Excel.Worksheet = Nothing
Dim newxlworkbooks As Excel.Workbook = Nothing
Dim newxlworkbook As Excel.Workbook = Nothing
Dim newxlworksheet As Excel.Worksheet = Nothing
Dim String2Search4 As String = "1000" 'String to search for.
Dim ColumnNumber As Integer = 4
xlApp = CreateObject("Excel.application")
newxlApp = CreateObject("Excel.application")
xlWorkBook = xlApp.Workbooks.Open("C:\spreadseet1.xlsx")
newxlworkbook = newxlApp.Workbooks.Open("C:\spreedsheet2.xlsx")
newxlworksheet = newxlworkbook.Worksheets("Sheet1")
xlWorkSheet = xlWorkBook.Worksheets("Sheet1")
For X As Integer = 1 To xlWorkSheet.Rows.Count Step 1
'check if the cell value matches the search string.
If xlWorkSheet.Cells(X, ColumnNumber).value = String2Search4 Then
MsgBox("Found " & String2Search4 & " in row " & X)
Dim rowfound As String = (X.ToString + ":" + X.ToString)
**xlWorkSheet.Copy(xlWorkSheet.Cells(2, 2), newxlworksheet.Cells(1, 1))**
newxlworkbook.Close()
xlWorkBook.Close()
End If
Next
--Thanks