Descrição:
Quando um programa está em execução, é possÃvel dar foco e trazê-lo para frente (em primeiro plano) via scripts?
Solução:
Sim. Para isto, utilize o script abaixo:
Sub CommandButton1_Click()
‘Utilizando o Método do Viewer: ExecuteExternalApp
Set Service = GetObject(“winmgmts:”)
strProgramPath = “C:\Windows\system32\calc.exe”
For Each Process in Service.InstancesOf(“Win32_Process”)
If Process.Name = “calc.exe” Then
running = True
End If
Next
If running Then
 MsgBox “Calculadora já está sendo executada!”
Set WshShell = CreateObject(“WScript.Shell”)
WshShell.AppActivate “calculadora”
newkeys = “% R”   ‘Maximiza objeto ativo
 WshShell.SendKeys newkeys
Else
 Application.ExecuteExternalApp strProgramPath, “”, “”, 1   ‘Pode ser substituÃdo por objShell.Run strProgramPath
End If
End Sub
NOTA: É também possÃvel realizar este comando com o objeto Shell (veja a aplicação em anexo).Â
