【问题标题】:Get size of worksheet area in Excel VBA在 Excel VBA 中获取工作表区域的大小
【发布时间】:2017-08-17 07:20:58
【问题描述】:

我需要在 Excel VBA 中获取工作表区域的宽度和高度(以像素为单位)。这是显示工作表中单元格的区域。因此,它必须排除所有其他 Excel UI 元素。我尝试使用 GetSystemMetrics 和 SystemParametersInfo 但没有找到解决方案。

【问题讨论】:

  • 检查Window对象的属性和方法

标签: excel vba pixels area worksheet


【解决方案1】:

也许下面的代码会有所帮助:

MsgBox ("Width in points = " & ActiveWindow.Width & Chr(13) & _ 
"Depth in points = " & ActiveWindow.Height & Chr(13) & _ 
"Width in Pixels = " & ActiveWindow.PointsToScreenPixelsX(ActiveWindow.Width) & Chr(13) & _ 
"Depth in Pixels = " & ActiveWindow.PointsToScreenPixelsY(ActiveWindow.Height)) 

最初在这里找到的代码:http://www.ozgrid.com/forum/showthread.php?t=36696 (by Ger Plante)

【讨论】:

  • 这给了我错误的值。它打印: 宽度(点):1036,5 深度(点):565,5 宽度(像素):-285 深度(像素):524 它应该打印宽度(点):221,29 深度(点):489 宽度(像素):1554 深度以像素为单位:652
猜你喜欢
  • 1970-01-01
  • 2022-12-21
  • 2021-07-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-24
  • 1970-01-01
相关资源
最近更新 更多