Question A first chance exception of type 'System.Runtime.InteropServices.COMException' occurr

prasoon99

New member
Joined
Apr 18, 2010
Messages
1
Programming Experience
10+
I'm using Visual Basic 2010 Express

I get the following error message SIX times before the code reaches the line marked ***:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Code:
-----
Module Module1

Sub Main()
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet

xlApp = New Microsoft.Office.Interop.Excel.Application (***)
'xlWorkBook = xlApp.Workbooks.Open("C:\Button.xlsm")
xlWorkBook = xlApp.Workbooks.Open("C:\test.xlsx")
xlWorkSheet = xlWorkBook.Worksheets("sheet1")

xlApp.Visible = True
xlWorkBook.Activate()
End Sub

End Module

Among others, MS Excel 12.0 and MS Office 12.0 Object Libraries are referenced. Can anyone help me with what is going on?

-Prasoon
 
I get the same error with similar code to you. At first I thought it was down to regional settings between the computer and excel but still get the same error.

If I press CTRL and F5 I don't get the error.

Have you managed to sort it?
 

Latest posts

Back
Top