Trouble with appactivate

buratti

Registered User.
Local time
Yesterday, 22:09
Joined
Jul 8, 2009
Messages
234
I have a button that should "activate" (or set focus to) my Quickbooks application. I have hardcoded the title bar caption into the appactivate function and yesterday it worked just fine. Today it would not, but I realized why. The title bar of my QuickBooks application changes depending on user logged on and mode (multi-user/single-user). I have searched around for alternatives for a workaround, but have come up short handed. Is there any way to retreive the tital bar caption of the QuickBooks application beforehand and then use that title in the appactivate function?
I have tried some of the following, but no luck...

Looked into the FindWindow API function, but just couldn't grasp the understanding of it, plus unless I am wrong, I needed the title bar caption of that anyway.

I used the shell() function to get the appID and send the appId to the appactivate function, but that did not work either. The reason i believe is because QuickBooks will ALWAYS already be running before my appactivate function is called, and using the shell() appears like it is opening another copy (according to my task bar) of Quickbooks then realizing a copy is already open so shuts that "second copy" down, essentially giving the wrong appID.

Any other suggestions?

What I have so far:
Code:
[COLOR=seagreen]'Sets focus to the quickbooks window[/COLOR]
Dim appID As String
 
appID = Shell("C:\Program Files\Intuit\QuickBooks 2008\QBW32Pro.exe", 1)
AppActivate appID [COLOR=seagreen]' the hard code that changes:"Quickbooks Pro 2008[/COLOR](multi-user)(Joe)"
 
Thanks. I looked it up a little (never used it or heard of it before) and at least what I grasped from this article is that the GetObjects function is used for MS Office applications only. Now I am probalby WAY off on that assumption though, but i need the window caption of my QuickBooks application and cannot figure out how to use it in the mannor I need. If it can be used for other (non Office) applications, can you please provide more information on how to use it?

However, after more research on other ways of getting the caption, I did find this site, explaining how to get the window caption of an open window using a wildcard string. This is exactly what would work for me, but seems a little elaborate for my particular situation, and anyway, i couldn't get it to work even when I copied their sample line for line. Specifically on the line:
Call EnumWindows(AddressOf EnumWindowProc, VarPtr(Parameters))
I get an error "Invalid use of AddressOf operator"

Any suggestion on how to get either method of retrieving the window caption of my quickbooks application window?
 

Users who are viewing this thread

Back
Top Bottom