workbook_open()
function which will be executed when the Workbook is opened. option explicit sub workbook_open() ' { msgBox "Workbook was opened" end sub ' }
create.wsf
is the script that creates the Excel workbook (createOfficeApp(…)
and inserts thisWorkbook.vb
(replaceThisWorkbookModule(…)
). <job> <script language="VBScript" src="..\..\..\create-MS-Office-app.vbs" /> <script language="VBScript"> option explicit dim app dim xls set xls = createOfficeApp("excel", currentDir() & "created.xlsm") set app = xls.application call replaceThisWorkbookModule(app, currentDir() & "thisWorkbook.vb") xls.save wscript.echo("The end") </script> </job>
cmd.exe
, PowerShell) like so; P:\ath\to\dir\> cscript create.wsf