PDA

View Full Version : taking application focus away from 3rd party software



sandam
03-16-2005, 04:15 AM
Hi all.

I've posted this problem before in Word help and thought I'd give it one more try in this section. Is there any way to force focus from another application on Word, using VBA (the macro would be running behind the third party software)? i've tried API calls as well as ".Activate" and ".SetFocus" but none of this works the second time around. the third party swoftware only releases focus on creation of the first document.

Any help would really be appreciated.
thanks
Andrew;?

I'm working with Office 2003 ad Windows XP and the third party software that creates the word doucments is called AIM Evolution (a lawfirm back office system) with Sculptor as the front end.

Brandtrock
03-16-2005, 05:55 PM
Have you tried AppActivate ("Microsoft Word")?

Regards,

sandam
03-17-2005, 08:43 AM
Just tried it and I got an invalid procedure call/invalid argument - poop! Maybe I used it in the wrong context. do you maybe have and example you could post to show how I could integrate it?

Brandtrock
03-17-2005, 09:42 AM
From Microsoft (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthappactivate.asp)

Example

The following example demonstrates the use of a single .wsf file for two jobs in different script languages (VBScript and JScript). The functionality of both jobs is the same ? each runs the Windows calculator and sends it keystrokes to execute a simple calculation.

The following example starts the Windows calculator and uses AppActivate to ensure that the calculator is at the top.

<package>
<job id="vbs">
<script language="VBScript">
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 100
WshShell.AppActivate "Calculator"
WScript.Sleep 100
WshShell.SendKeys "1{+}"
WScript.Sleep 500
WshShell.SendKeys "2"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 500
WshShell.SendKeys "*3"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 2500
</script>
</job>

<job id="js">
<script language="JScript">
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.Run("calc");
WScript.Sleep(100);
WshShell.AppActivate("Calculator");
WScript.Sleep(100);
WshShell.SendKeys("1{+}");
WScript.Sleep(500);
WshShell.SendKeys("2");
WScript.Sleep(500);
WshShell.SendKeys("~");
WScript.Sleep(500);
WshShell.SendKeys("*3");
WScript.Sleep(500);
WshShell.SendKeys("~");
WScript.Sleep(2500);
</script>
</job>
</package>


HTH,

sandam
03-18-2005, 03:46 AM
Okay. It makes sense. Now how would I integegrate that into a VBA macro. I'm guessing ("Scripting.FileSystemObject") or something similar but I'm not sure??