title: Need VBScript to import BAS file to Excel with relative directory or alternative
body: <p>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?</p>
  
  <p>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.</p>
  
  <p>Current functional but not ideal code:</p>
  
  <pre><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"
  </code></pre>