
I keep getting this error above.
I then Tried adding this top reference (See image below).

But this not solve the error.
How do I fix the issue?
Thanks,
Ed

I keep getting this error above.
I then Tried adding this top reference (See image below).

But this not solve the error.
How do I fix the issue?
Thanks,
Ed
Hi,@ EduardsGzibovskis-2327. Could you show me your complete code to analyze and reproduce the problem?
Hi,
This works on .NET Framework but not on .NET 5.0
Also, I realised the following:
.NET Framework:
VBE shows up

.NET 5.0:
VBE does not show up

See below example:
using Excel = Microsoft.Office.Interop.Excel;
// Load Excel sheet
var excelApp = new Excel.Application();
Excel.Workbooks books = excelApp.Workbooks;
Excel._Workbook sheet = books.Open("path to Excel");
// Load macro to excel
excelApp.VBE .ActiveVBProject.VBComponents.Item("Sheet1").CodeModule.AddFromFile(@"G:\Templates\VBA.txt");
// Show the file
excelApp.Visible = true;
// Run the internal Macro
excelApp.Application.Run("Sheet1.merg");
Hi,@ EduardsGzibovskis-2327. May I know if you have got any chance to check my answer? I am glad to help if you have any others questions.
The error shows that Microdoft.Vbe.Interop is missing. So I tried to add ExcelDna.Interop, which contains Microdoft.Vbe.Interop. You could try to see if it matches your program.

And then the error disappeared.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
6 people are following this question.