Excel 2010 VBA代码将屏幕复制到剪贴板上

问题描述 投票:0回答:1

我正在寻找Excel 2010中的VBA代码,它将允许我在Excel中对特定范围进行屏幕截图。

现在,当我在Excel中选择一个范围,然后复制,视图与实际屏幕视图失真。

如果你有任何问题,请告诉我,谢谢。

excel-vba vba excel
1个回答
1
投票

http:/support.microsoft.comkb240653

这个链接完全可以满足我的需求。

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
© www.soinside.com 2019 - 2024. All rights reserved.