Run Excel Macro from Outside Excel Using VBScript From Command Line

Ok, it’s actually simple. Assuming that your macro is in a module,not in one of the sheets, you use: objExcel.Application.Run “test.xls!dog” ‘notice the format of ‘workbook name’!macro For a filename with spaces, encase the filename with quotes. If you’ve placed the macro under a sheet, say sheet1, just assume sheet1 owns the function, which it … Read more

How to do a single line If statement in VBScript for Classic-ASP?

The conditional ternary operator doesn’t exist out of the box, but it’s pretty easy to create your own version in VBScript: Function IIf(bClause, sTrue, sFalse) If CBool(bClause) Then IIf = sTrue Else IIf = sFalse End If End Function You can then use this, as per your example: lunchLocation = IIf(dayOfTheWeek = “Tuesday”, “Fuddruckers”, “Food … Read more

Is it possible to embed and execute VBScript within a batch file without using a temporary file?

Note – jump to the UPDATE 2014-04-27 section at the bottom of this answer for the best solution. I used to think the answer was no. But then DosTips user Liviu discovered that the <SUB> character (Ctrl-Z, 0x1A, decimal 26) has bizare effects when embedded within a batch file. If functions somewhat like a line … Read more