I need to create a new Excel file (from a .csv) and import two macro files: One .bas and one .cls. The first import works, but the second one is not imported to ThisWorkbook, but to a new class module.
At first I create the new excel file object from my existing csv file.
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(srcFile)
Then the .bas is imported to the modules directory by:
oBook.VBProject.VBComponents.Import scriptPath & "\" & "MyMacro" & ".bas"
When I do the same call for the .cls file it is imported to a new class module directory and not to ThisWorkbook.
oBook.VBProject.VBComponents.Import scriptPath & "\" & "RightClickEntry" & ".cls"
It must be imported to ThisWorkbook because it adds an entry to the right-click context menu which will else not be shown.