I have a VBA module and a VBScript that imports this module into a specific Excel Workbook. The problem I'm facing is when using a different machine, the path to the module will change. Is there a way to package the BAS file with the Script file? Or to have the BAS within the actual VBScript file?
Ideally the final product would be a single file, it is possible to send both the Vbscript and the BAS file together (possibly zipped) but I would prefer a one-file deliverable. Unfortunately converting the VBA module to VBS is not really an option, as I specifically need some of the VBA functionality.
Current functional but not ideal code:
'Target Excel file to import BAS file to
Filepath = "C:\targetExcelFile.xlsx"
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(filepath)
objExcel.Visible = True
'Imports BAS module, but using a filepath
objExcel.VBE.ActiveVBProject.VBComponents.Import pathToBASfile
objExcel.Run "MySub"