Clay,
in XP with SP2
with other worksheets open and also WatchLists.xls open
when I try:
taskkill /FI "WindowTitle eq Microsoft Excel - WatchLists.xls"
I get:
ERROR: Invalid Argument/Option - 'WatchLists.xls'.
The title is right according to the Excel title bar.
As other worksheets are open
the Task Manager shows the title as only 'WatchLists.xls'.
but when I try:
taskkill /FI "WindowTitle eq WatchLists.xls"
I get:
INFO: No tasks running with the specified criteria.
I have also tried other variations eg:
taskkill /F /FI "WindowTitle eq Microsoft Excel - WatchLists.xls"
etc.
but always the error message appears.
Thank you for your past help and - any suggestions ?
Interesting. I was able to replicate your scenario. It looks like
only one instance of Excel is running, even though two Excel items are
on the TaskBark. I just noticed that even though there are two items
on the taskbar, there is really only one Excel window open.
This VBscript worked for me, YMMV.
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Microsoft Excel - Katherine's Family tree.xls"
WScript.Sleep 1000
WshShell.SendKeys "^w"
WScript.Sleep 2500
You can test the first timeout value, but I'd leave the bottom one
alone.
VBscript can only send keys to the active window. I believe
higher-end languages can send to windows if they know the 'handle'.
HTH
Clay Calvert
(e-mail address removed)
Replace "W" with "L"