Your code only works if you test the booleans like this:
bResult = objShell.AppActivate("App Title")
if bResult then
'do something
end if
if not bResult then
'do something else
end if
AppActivate seems to return TRUE if it has found a window title beginning or
ending with/in the specified string (not case sensitive), FALSE otherwise.
The wild thing is that if you set
bResult=TRUE
then the code in the if-clause is run:
MsgBox(bResult) 'the popup contains True or Wahr or ... (it's
localised!)
if bResult=TRUE then ... end if
BUT! Even if AppActivate returns a boolean value TRUE, the same clause won't
run now:
bResult=objShell.AppActivate("Explorer")
MsgBox(bResult) 'the same message as before
if bResult=TRUE then
... 'this won't be executed!
end if
So, the docs should be updated to cover the return result of AppActivate and
something about boolean arithmetics, this would be really enlightning.
D Samuelsson <IMCEAEX-> schrieb in im Newsbeitrag:
143C6B82A8F1D211BBC200105A67CEF816B41C@JIM...
I've seen a few postings on the AppActivate method and have just done a
little function to sit in an ie5 browser to launch applications (a simple
"control panel" for a terminal server environment)
I have the following VB script to check for an instance of an application
running and either switch to or launch this app.
Function RunTheApp()
Dim iReturn
Dim objShell
Dim bResult
Set objShell = CreateObject("WScript.Shell")
bResult = objShell.AppActivate("App Title")
If bResult<>False then
objShell.SendKeys "%( x)"
End If
If bResult=False then
iReturn = objShell.Run("App Command Line")
End If
End Function
Or words to that effect ...
Now what has me puzzled is what is returned from the AppActivate method.
Looking at what it returns it looks to be a boolean result but if I have my
first condition as "if bResult=True" that clause never gets run.
Have I missed something here ? Does AppActivate return a False if it can't
find the app and something other than true if it does ?
"D Samuelsson" <IMCEAEX-> wrote in message news:143C6B82A8F1D211BBC200105A67CEF816B41C@JIM...