Resolved Problems VB.NET and Excel

Ab99

Member
Joined
Dec 19, 2021
Messages
8
Location
Netherlands
Programming Experience
3-5
Hello,
I have an problem with my program, Windows Form based.
My laptop with Windows 10 and Office 2007 does not have any problems. I can open Excel from my program.

With an other laptop, Windows 10 and excel it gives some problems. I get this fault:
foutmelding startlijsten.JPG


I am working with Visual Studio 2019 or 2022.
My reference :
reference.JPG


What can I do to get this right?
 
You haven't explained if they are different Office versions, but with the modern developer approach of "embed interop types" this by itself should not be a problem as long as you're using compatible types and members. In earlier days a specific PIA had to be targeted. Here it is the Application in question, and that is common. If you do have embedded interop types I'm guessing the problem is different bitness for the Office installations.
 
There are indeed different office version and so also Excel versions.
My application should work with all types.

My last test result: If the user has no admin rights on the pc or laptop then this Problem is there.
When he is administrator on the pc or laptop, then excel functions.
 
If the user doesn't have Excel then your app that interops Excel won't work too.
 
Is there an easy way to prevent the fault to happen when excel is not on the pc?
Is there an other/ simple way then try and catch?

In my Program I will start Excel:
objApp = New Microsoft.Office.Interop.Excel.Application()

How can I try and catch if Excel is opend and prevent the error:

foutmelding startlijsten.JPG
 
Last edited:
VB.NET:
Dim Excel_Available = Type.GetTypeFromProgID("Excel.Application") IsNot Nothing
 
Back
Top