Creating an Excel Object using VB.NET.
Hi everyone,
This is my problem:
I am trying to create an excel object so I can run an excel macro.
This is the code I a using:
Dim oExcelAs Excel.ApplicationClass
Dim oBookAs Excel.WorkbookClass
Dim oBooksAs Excel.Workbooks
Dim missingAsObject = System.Reflection.Missing.Value
Me.TextBox1.Text =Me.TextBox1.Text + " Report Creation in progress Please Wait..." + vbCrLf
'Start Excel and open the workbook.
oExcel =
DirectCast(CreateObject("Excel.Application"), Excel.Application)oExcel.Visible =
FalseoBooks = oExcel.Workbooks
oBook = oBooks.Open("C:\Developpement\Project_RCP\RCP_App\Job Bruts\Job RCP.xls", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
'running the macrosoExcel.Run("MacroJob")
'Clean-up: Close the workbook and quit Excel.Me.TextBox1.Text =Me.TextBox1.Text + " Report Successfully Created..." + vbCrLf
oBook.Close(False)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
oBook =Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
oBooks =
NothingoExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel =
NothingThe red line gives me the following error message:
Cannot cast a COM object of type Microsoft.Office.Interop.Excel.ApplicationClass into a Classe Excel.ApplicationClass type .
The funny thing is this code does work on my PC where I wrote but it cannot run on my colleague's PC who is actually the end user.
Thank you for your help

