Hello,
I am trying to open an excel file from vb.net console application.
Imports System
Imports System.Data
Imports Microsoft.Office.Interop
Module Module1
#Region "variables"
Dim xlapp As Excel.Application
Dim wbk As Excel.Workbook
Dim wsht As Excel.Worksheet
Dim i, j, rowcnt, colcnt As Integer
#End Region
Sub Main()
xlapp = CreateObject("Excel.Application")
wbk = xlapp.Workbooks.Open("D:\TEMPLATE\temp.xlsx")
wsht = wbk.Worksheets(1)
//data retreival & pasting into excel//
wbk.SaveAs("D:\REPORT\test.xlsx")
wsht = Nothing
wbk = Nothing
xlapp.Quit()
xlapp = Nothing
GC.Collect()
End Sub
End Module
This line throws the error
wbk = xlapp.Workbooks.Open("D:\TEMPLATE\temp.xlsx")
error is
COMException was unhandled - The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
Reference for excel included-->
Microsoft.Office.Interop.Excel
I am using Visual Studio 2010 32 bit with framework 3.5 and office 365.
Kindly help as the same code runs fine in another machine that has office 2010 instead of office 365 and rest same.
As I searched on internet, some solutions said to install office on server. Don't know if there is something with office 365.
Thank you....!! :)
What I have tried:
searched for solution but couldn't find any.