我正在寻找 Excel 2010 中的 VBA 代码,它可以让我在 Excel 中截取特定范围的屏幕截图。
现在,当我在 excel 中选择一个范围,然后复制时,视图与实际的屏幕视图失真。
如果您有任何问题,请告诉我 - 谢谢。
http://support.microsoft.com/kb/240653
这个链接非常适合我需要的东西。
64位的完整代码如下:
Private Declare PtrSafe Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare PtrSafe Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Integer
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
Dim blnAboveVer4 As Boolean
Sub takeScreenShot()
If blnAboveVer4 Then
keybd_event VK_SNAPSHOT, 0, 0, 0
Else
keybd_event VK_SNAPSHOT, 1, 0, 0
End If
End Sub