Jozsef Creative Commons License 2007.01.08 0 0 4716

Ezek kellhetnek még hozzá (ha minden verzión kell működni):

 

 

Declare Function GetDesktopWindow Lib "user32" () As Long

 

 

Declare Function FindWindowEx Lib "user32" _
    Alias "FindWindowExA" _
    (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
    ByVal lpsz1 As String, ByVal lpsz2 As String) _
    As Long

 

Declare Function GetCurrentProcessId Lib "kernel32" () _
    As Long

 

Declare Function GetWindowThreadProcessId Lib "user32" _
    (ByVal hWnd As Long, ByRef lpdwProcessId As Long) _
    As Long

 

Function ApphWnd() As Long

 If Val(Application.Version) >= 10 Then
  ApphWnd = Application.hWnd
 Else
  ApphWnd = FindOurWindow("XLMAIN", Application.Caption)
 End If

End Function

 

 

Public Function FindOurWindow( _
     Optional sClass As String = vbNullString, _
     Optional sCaption As String = vbNullString)

 Dim hWndDesktop As Long
 Dim hWnd As Long
 Dim hProcThis As Long
 Dim hProcWindow As Long

 hProcThis = GetCurrentProcessId

 hWndDesktop = GetDesktopWindow

 Do
  hWnd = FindWindowEx(hWndDesktop, hWnd, sClass, _
            sCaption)

 Loop Until hProcWindow = hProcThis Or hWnd = 0

 FindOurWindow = hWnd

End Function

 

 

és a

az előző kódba

opfile.hWndOwner = ApphWnd()

kell

opfile.hWndOwner = Application.hWnd

helyett

Üdv

József

Előzmény: Vacy (4715)