I created a task in the Windows 7 schtasks tool. It reminds me on the 15th of the month, by opening an excel workbook that I should look at and update. Handy.
Problem is, there is about a 60% chance I already have Excel open at the time this pops up, and I suppose a small chance I even have that workbook open. Then the result is not at all elegant. The task tries to open another copy of Excel and this complains about read-only access, and likewise with the workbook itself.
Is there a way in SCHTASKS, or in a BATCH file (or any other handy Windows tool you'd recommend) to first check if Excel is open and then if it is, just switch to it, rather than open a second copy of Excel? I've seen a note about using TASKLIST in a .BAT file to check if it is open:
TASKLIST /FI "IMAGENAME eq EXCEL.EXE" 2>NUL | FIND /I /N "EXCEL.EXE">NUL
IF "%ERRORLEVEL%" EQ "0" START excel "C:\Project4\MonthlyTracking.xlsx"
but I don't know how to react in the BATCH file if it is open. I don't see a way in a BATCH file to tell the already-running excel process to open a file.
Many thanks!