設為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

返回列表 發(fā)新帖
查看: 2293|回復: 2
打印 上一主題 下一主題

[API] 使用API的Findwindow函數(shù)獲取Excel窗口的大小

[復制鏈接]

點擊這里給我發(fā)消息

跳轉到指定樓層
1#
發(fā)表于 2015-6-10 10:23:30 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式

使用API的Findwindow函數(shù)獲取Excel窗口的大小

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal ClassName As String,ByVal WindowName As String) As Long
Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long,Rect As Rect) As Long

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

'顯示EXCEL窗口的位置及大小
Public Sub ShowExcelWindowSize()
  Dim hWnd As Long, aRect As Rect
  hWnd = FindWindow("XLMAIN", Application.Caption) 'XLMAIN是EXCEL窗口的類名
  Call GetWindowRect(hWnd, aRect)
  ’打印 窗體的上下左右位置及寬度和高度
  Debug.Print " Left: " & aRect.Left
  Debug.Print " Right: " & aRect.Right
  Debug.Print " Top: " & aRect.Top
  Debug.Print " Bottom: " & aRect.Bottom
  Debug.Print " Width: " & (aRect.Right - aRect.Left)
  Debug.Print " Height: " & (aRect.Bottom - aRect.Top)
End Sub
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享分享 分享淘帖 訂閱訂閱

點擊這里給我發(fā)消息

2#
發(fā)表于 2015-6-11 05:16:55 來自手機 | 只看該作者
這個結合打開不錯。

點擊這里給我發(fā)消息

3#
發(fā)表于 2015-6-11 05:17:46 來自手機 | 只看該作者
setwindowposition
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則

QQ|站長郵箱|小黑屋|手機版|Office中國/Access中國 ( 粵ICP備10043721號-1 )  

GMT+8, 2025-7-13 08:12 , Processed in 0.116446 second(s), 30 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表