vb.net open multiple excel files in invisible mode

1

This is my code to open multiple excel file to do some calculation based on their content.

Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop

Module Module1

Sub Main()

    Dim xlApp As Excel.Application
    Dim wb1 As Excel.Workbook
    Dim wb As Excel.Workbook
    Dim w As Excel.Worksheet

    xlApp = New Excel.Application
    xlApp.Visible = True

    wb1 = xlApp.Workbooks.Open("E:\xls\f.xls")
    wb = xlApp.Workbooks.Open("E:\xls\b.xls")
    w = wb1.ActiveSheet


End Sub

End Module

This code runs and it's ok,but i want to not show excel application and i uncomment the line that set xlApp.Visible=True .but this exception occures:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ConsoleApplication12.exe

Additional information: The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

So,What do i have to do?

vb.net
excel
asked on Stack Overflow Jun 1, 2016 by M.ah

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0