Public Sub Create_and_Run_VBScript()
Dim VBScriptFile As String
Dim fileNum As Integer
'Create the VBScript.vbs file
VBScriptFile = Environ("temp") & "\VBScript.vbs"
fileNum = FreeFile
Open VBScriptFile For Output As fileNum
Print #fileNum, "Option Explicit"
Print #fileNum, "Dim Excel, Wb"
Print #fileNum, "Set Excel = GetObject(, ""Excel.Application"")"
Print #fileNum, "Set Wb = Excel.Workbooks(""" & ThisWorkbook.Name & """)"
Print #fileNum, "Wb.Worksheets(1).Range(""A1"").Value = Now"
Close fileNum
'Debugging aid - open the script in Notepad
Shell "Notepad " & VBScriptFile
'Run the script
Shell "wscript " & Chr(34) & VBScriptFile & Chr(34), vbNormalFocus
End Sub