Dim wdApp
Dim tsk
Dim blfinished
Set wdApp = CreateObject("Word.Application")
wdapp.Visible = False
blfinished = False
do while blfinished <> true
wscript.sleep 1000
For each tsk in wdApp.Tasks
'\\ Get the exact task name of tfsdialog first
If Instr(tsk.Name,"tfsdialog") > 0 then
tsk.close
blfinished = true
end if
Next
Loop
wdApp.Quit
Set wdApp = Nothing
Dim wdApp
Dim wShell
Dim tsk
Dim blfinished
Set wdApp = CreateObject("Word.Application")
Set wShell = CreateObject("WScript.Shell")
wdapp.Visible = False
blfinished = False
do while blfinished <> true
wscript.sleep 1000
For each tsk in wdApp.Tasks
'\\ Get the exact task name of tfsdialog first
If Instr(tsk.Name,"Excel") > 0 then
tsk.Activate
wShell.SendKeys "{ENTER}"
blfinished = true
end if
Next
Loop
wdApp.Quit
set wShell = Nothing
Set wdApp = Nothing
'\\ Get the exact task name of tfsdialog first
If Instr(tsk.Name,"tfsdialog") > 0 then
tsk.activate
wShell.SendKeys "{ENTER}"
end if
Public Sub RunningTasks()
Dim tsk As Task
Dim strTaskList As String
For Each tsk In Application.Tasks
If tsk.Visible Then
strTaskList = strTaskList & vbCrLf & tsk.Name & "|" & tsk.Application & "|" & tsk.Parent
End If
Next
ActiveDocument.Range.Text = strTaskList
End Sub