[AccessD] [Fwd: Re: Word Window On Top]

Rocky Smolin - Beach Access Software bchacc at san.rr.com
Sun Aug 27 18:52:23 CDT 2006


Thanks, Marty.  I'll let you know what happens.

Rocky


MartyConnelly wrote:
> This works for me from Access 2003 vs Word 97 or Word2007
> Some of these API calls had little glitches prior to WinXP.
> And were different in Win9x.
>
> You may need all three API calls SetActiveWindow,
> ShowWindow and SetForegroundWindow.
>
>
>
>     'Windows API Declarations
>    Private Declare Function SetActiveWindow Lib "user32.dll" (ByVal hwnd 
> As Long) As Long
>    Private Declare Function ShowWindow Lib "user32" _
>      (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
>    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
>    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
>    Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd 
> As _
>     Long) As Long
>  
>     Const SW_SHOW = 9
>    
>     Sub testme()
>     Dim x As Long
>      x = AppActivateClass("OpusApp") 'Word ClassName
>      Debug.Print x
>     End Sub
>
>     '******************************************************************
>     ' FUNCTION: AppActivateClass()
>     '
>     ' PURPOSE: Used to activate another application by using its
>     '    class name instead of the title bar text as AppActivate does.
>     '
>     ' ARGUMENTS:
>     '    strClassName   - The Class Name of the application.
>     '
>     ' RETURNS:
>     '     0   - The application was not found - it either was not running
>     '           or the class name is incorrect
>     '    -1   - The application was activated
>
>     '******************************************************************
>
>     Function AppActivateClass(strClassName As String)
>       Dim hwnd As Long     'the application's window handle
>       Dim dummy As Long     'Dummy variable
>       'Dim strClassName As String
>       'strClassName = "OpusApp" 'for Word; Opus was orignal beta name of 
> word
>                             ' or perhaps somebody's cat
>       'Get the Window Handle
>        hwnd = FindWindow(strClassName, vbNullString) '0& doesn't work
>                    'hWnd = FindWindow(lpclassname, by Val 0&)
>       Debug.Print "handle =" & hwnd
>       'Activate the Application
>       dummy = ShowWindow(hwnd, SW_SHOW) ' call needed to restore if app 
> minimized
>                                         ' else only tray icon activated
>       dummy = SetActiveWindow(hwnd)
>       dummy = SetForegroundWindow(hwnd)
>
>       'Return True if Application Running, or False if not.
>       AppActivateClass = hwnd
>     End Function
>
> Rocky Smolin - Beach Access Software wrote:
>
>   
>> Thanks.  Will forward.
>>
>> Rocky
>>
>>
>> William Hindman wrote:
>>  
>>
>>     
>>> Rocky
>>>
>>> ...your client isn't the only one with that particular problem ...and it 
>>> appears to be workstation dependent ...on most systems the Activate command 
>>> does bring the Word doc to the front ...but not all.
>>>
>>> ...you might want to give this a look if the problem still exists:
>>>
>>> http://xphelpandsupport.mvps.org/how_do_i_prevent_applications_fr.htm
>>>
>>>
>>> William Hindman
>>>
>>> ----- Original Message ----- 
>>> From: "Rocky Smolin - Beach Access Software" <bchacc at san.rr.com>
>>> To: "Access Developers discussion and problem solving" 
>>> <accessd at databaseadvisors.com>
>>> Sent: Sunday, August 27, 2006 12:15 AM
>>> Subject: Re: [AccessD] Word Window On Top
>>>
>>>
>>>  
>>>    
>>>
>>>       
>>>> Word is OpusApp and Access is OMain.  That makes sense (not).
>>>>
>>>> Anyway, thanks - I'll forward the snip to the client and see if that
>>>> will do it.
>>>>
>>>> Best,
>>>>
>>>> Rocky
>>>>
>>>>
>>>> Michael R Mattys wrote:
>>>>    
>>>>      
>>>>
>>>>         
>>>>> Hi Rocky,
>>>>>
>>>>> No - OpusApp is the Application name.
>>>>> Most Office Apps are like that
>>>>> Try here: http://www.mvps.org/access/api/api0007.htm
>>>>>
>>>>> Michael R. Mattys
>>>>> MapPoint Developer
>>>>> www.mattysconsulting.com
>>>>>
>>>>> ----- Original Message ----- 
>>>>> From: "Rocky Smolin - Beach Access Software" <bchacc at san.rr.com>
>>>>> To: "Access Developers discussion and problem solving"
>>>>> <accessd at databaseadvisors.com>
>>>>> Sent: Saturday, August 26, 2006 9:48 PM
>>>>> Subject: Re: [AccessD] Word Window On Top
>>>>>
>>>>>
>>>>>
>>>>>      
>>>>>        
>>>>>
>>>>>           
>>>>>> Replace OpusApp with WordObj?
>>>>>>
>>>>>> Rocky
>>>>>>
>>>>>>
>>>>>> Michael R Mattys wrote:
>>>>>>
>>>>>>        
>>>>>>          
>>>>>>
>>>>>>             
>>>>>>> Of course! Right on target, John.
>>>>>>>
>>>>>>> I was going to say:
>>>>>>>
>>>>>>> Public Declare Function FindWindow Lib "user32" _
>>>>>>> Alias "FindWindowA" (ByVal lpClassName As String, _
>>>>>>> ByVal lpWindowName As String) As Long
>>>>>>>
>>>>>>> Public Declare Function ShowWindow Lib "user32" _
>>>>>>> (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
>>>>>>>
>>>>>>> Dim OpusApp As Long
>>>>>>> OpusApp& = FindWindow("OpusApp", vbNullString)
>>>>>>> Call ShowWindow(OpusApp , SW_NORMAL)
>>>>>>>
>>>>>>> Michael R. Mattys
>>>>>>> MapPoint Developer
>>>>>>> www.mattysconsulting.com
>>>>>>>
>>>>>>> ----- Original Message ----- 
>>>>>>> From: "John Ruff" <papparuff at comcast.net>
>>>>>>> To: "'Access Developers discussion and problem solving'"
>>>>>>> <accessd at databaseadvisors.com>
>>>>>>> Sent: Saturday, August 26, 2006 9:07 PM
>>>>>>> Subject: Re: [AccessD] Word Window On Top
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>          
>>>>>>>            
>>>>>>>
>>>>>>>               
>>>>>>>> After you create the WordObj set its visible property to true
>>>>>>>>
>>>>>>>> ' Shows this instance of Word
>>>>>>>> WordObj.Visible = True
>>>>>>>>
>>>>>>>> papparuff
>>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: accessd-bounces at databaseadvisors.com
>>>>>>>> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky
>>>>>>>> Smolin -
>>>>>>>> Beach Access Software
>>>>>>>> Sent: Saturday, August 26, 2006 4:26 PM
>>>>>>>> To: Access Developers discussion and problem solving
>>>>>>>> Subject: Re: [AccessD] Word Window On Top
>>>>>>>>
>>>>>>>> Well, I'm really crappin' out with this guy.  .Activate didn't work, 
>>>>>>>> nor
>>>>>>>> .Show.
>>>>>>>>
>>>>>>>> He tests to see if word is already open - doesn't want to open a 
>>>>>>>> second
>>>>>>>> instance.
>>>>>>>>
>>>>>>>> Set WordObj = GetObject(, "Word.Application")
>>>>>>>>   If Err.Number <> 0 Then
>>>>>>>>        Set WordObj = CreateObject("Word.Application")
>>>>>>>>   End If
>>>>>>>>
>>>>>>>>
>>>>>>>> Nothing works so far when Word is already open.  But I can't help but
>>>>>>>> think there's a simple property or method (there's so freakin' many of
>>>>>>>> 'em) to make Word the active window when you open a new document and
>>>>>>>> word is already open.
>>>>>>>>
>>>>>>>> Any other ideas anybody?
>>>>>>>>
>>>>>>>> MTIA
>>>>>>>>
>>>>>>>> Rocky
>>>>>>>>
>>>>>>>> Heenan, Lambert wrote:
>>>>>>>>            
>>>>>>>>              
>>>>>>>>
>>>>>>>>                 
>>  
>>
>>     
>
>   

-- 
Rocky Smolin
Beach Access Software
858-259-4334
www.e-z-mrp.com




More information about the AccessD mailing list