Excel Fails to Launch Using VB.NET

Member_2_7971199
Member_2_7971199 used Ask the Experts™
on
I use vb.net to launch and use Microsoft Excel.  There is 1 computer, however, that will not launch excel when I run this code:

Imports XL = Microsoft.Office.Interop.Excel

Public Class Form1

    Dim xlApp As New XL.Application
    Dim wb As XL.Workbook
 
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        wb = xlApp.Workbooks.Add()
    End Sub
End Class

I have references to Microsoft.Office.Core and Microsoft.Office.Interop.Excel.  I am using Visual Studio 2015 and the Excel on the user's machine is 2010 Professional Plus.

Please see the attached error.

Thank you,

Elliot Semmelman
error.docx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Analyst Assistant
Commented:
Elliot

What version of Excel Interop are you using?

Also, on the computers where the code works what version of Excel is installed?

What happens if you change to using late binding?
Public Class Form1

    Dim xlApp As Object
    Dim wb As Object
  
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        xlApp = CreateObject("Excel.Application")
        wb = xlApp.Workbooks.Add()
        xlApp.UserControl = True
    End Sub

End Class

Open in new window

Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
does the user has the same version of Office that you have installed?

Author

Commented:
It does work using late binding.  Thank you.

Several Questions:

1)  Does that help to pin point what the problem is?

2)  Is there a significant delay in processing using late binding vs. early binding?

3)  I removed the library reference, can you use all properties and methods using late binding?

Thanks.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Éric MoreauSenior .Net Consultant
Top Expert 2016
Commented:
1) development process can be slowed down because you don't get intellisense
2) somewhat yes but often not noticeable
3) yes but no compile time error. Only run time errors.
NorieAnalyst Assistant

Commented:
Elliot

1) It doesn't really 'pinpoint' the problem but it does suggest it could have something to do with different versions being in use.

2) As Éric there might be some slowdown but nothing  noticeable.

3) All properties and methods are still available.
NorieAnalyst Assistant

Commented:
Late binding was indicated as a solution.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial