* Fox code >>function fWin >>lParameters tuClass, tuWinTitle >>DECLARE integer FindWindow in WIN32API string cClass, string cWinName >>hWnd = FindWindow(tuClass,tuWintitle) >>clear dlls >>return hWNd >> >>? fwin("Fox_4000001","Microsoft Visual FoxPro") && 824 >>? fwin("Fox_4000001",0) && 832 >>? fwin(0,"Microsoft Visual FoxPro") && 824 >>? fwin(0,0) && 904>>
>Declare Function FindWindowA Lib "user32" (lpszClassName As String, lpszWindowName As String) As Long > >lnHandle = FindWindowA(0, "Microsoft Visual FoxPro") Hi Klas, For connection problems I can't browse the rest of thread. I'm unfortunately purely unfamiliar with VB so all I could do is to make some conversion from VFP into a word macro (tested - works :) <pre>Declare Function FindWindow Lib "user32" Alias _ "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Sub Macro1() Dim hWnd As Long ' Search tasks for a VFP session For Each myTask In Tasks ' Search by class + title If FindWindow("Fox_4000001", myTask.Name) > 0 Then ' Found a VFP session myTask.Activate ' Activate VFP session myTask.WindowState = wdWindowStateNormal ' Set VFP win state to normal Exit For End If Next myTask End SubSearch by both class and title, otherwise just a search by class might return a window handle that you would really have trouble to use via API (or it was just my disability to convert to VB :( ). If you know the exact title of VFP session you could also directly check myTask.name vs "Title" w/o using findwindow.