Uygulama FindWindow - GetWindowRect - Excel Penceresinin Ekrandaki Konumu

Murat OSMA

Yönetici
Site Yöneticisi
Katılım
25 May 2018
Mesajlar
1,327
En iyi yanıt
11
Puanları
113
Konum
İstanbul
Web sitesi
excelarsivi.com
Ad Soyad
Murat OSMA
Office Versiyon
Office 365 TR+EN
Excel penceresinin ekrandaki konumunu öğrenmek için bu kodları kullanabilirsiniz..

Modül kodları
PHP:
#If VBA7 And Win64 Then
    Private Public PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare PtrSafe Function GetWindowRect Lib "user32" _
    (ByVal hwnd As LongPtr, lpRect As Rect) As Long
#Else
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal ClassName As String, ByVal WindowName As String) As Long
    Public Declare Function GetWindowRect Lib "user32" _
    (ByVal hwnd As Long, Rect As Rect) As Long
#End If

Private Type Rect
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type

Sub Yerini_Göster()
    Dim hwnd As Long, Excel As Rect
    hwnd = FindWindow("XLMAIN", Application.Caption)
    Call GetWindowRect(hwnd, Excel)
    Range("A1").Value = "Left: " & Excel.Left
    Range("A2").Value = "Right: " & Excel.Right
    Range("A3").Value = "Top: " & Excel.Top
    Range("A4").Value = "Bottom: " & Excel.Bottom
    Range("A5").Value = "Width: " & (Excel.Right - Excel.Left)
    Range("A6").Value = "Height: " & (Excel.Bottom - Excel.Top)
End Sub
 
Son düzenleme:
Üst Alt