通过VBA自动截图,并保存到指定位置
时 间:2018-11-25 10:40:07
作 者:易勋 ID:35404 城市:上海
摘 要:通过VBA自动截图,并保存到指定位置
正 文:
函 数:
Option Compare Database Option Explicit Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Enum JpMode theScreen = 0 '全屏截图 theForm = 1 '当前焦点窗口截图 End Enum Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long Private Declare Function CloseClipboard Lib "user32" () As Long Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As Guid, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long Private Const CF_BITMAP = 2 Private Type PicBmp Size As Long Type As Long hBmp As Long hPal As Long Reserved As Long End Type Private Type Guid Data1 As Long Data2 As Integer Data3 As Integer Data4(0 To 7) As Byte End Type Function ApiGetClipBmp(bScan As JpMode) As IPicture On Error Resume Next Call keybd_event(vbKeySnapshot, bScan, 0, 0) ' DoEvents Dim Pic As PicBmp, IID_IDispatch As Guid OpenClipboard 0 'OpenClipboard With IID_IDispatch .Data1 = &H20400 .Data4(0) = &HC0 .Data4(7) = &H46 End With With Pic .Size = Len(Pic) .Type = 1 .hBmp = GetClipboardData(CF_BITMAP) End With OleCreatePictureIndirect Pic, IID_IDispatch, 1, ApiGetClipBmp CloseClipboard End Function
调用方法:
SavePicture ApiGetClipBmp(theForm), CurrentProject.Path & "\" & Format(Now, "yyyymmddhhnnss") & ".bmp"
调用说明:
先调用截图函数,需要给截图函数传递截图的类型:JpMode。然后将函数的返回值使用SavePicture保存到本地位置。
附 件:
演 示:
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- Access对子窗体数据进行批...(10.30)
- 最精简的组合框行来源数据快速输...(10.25)
- Access仿平台的多值选择器...(10.24)
- 【Access日期区间段查询】...(10.22)
- 【Access源码示例】VBA...(10.12)
- Access累乘示例,Acce...(10.09)
- 数值8.88,把整数8去掉,转...(10.08)
- 【Access自定义函数】一个...(09.30)
- 【Access选项卡示例】Ac...(09.09)
学习心得
最新文章
- Access判断多条明细的配方或订...(11.30)
- 如何让后台数据库在局域网共享时,且...(11.29)
- 【Access月初月末日期设置方法...(11.29)
- 【Access IIF函数嵌套示例...(11.26)
- Access快速开发平台--使用组...(11.25)
- Access快速开发平台--对上传...(11.22)
- Access快速开发平台企业版--...(11.18)
- 不会用多表联合查询,多表查询没结果...(11.16)
- 【案例分享】主键字段值含有不间断空...(11.16)
- Access快速开发平台--后台D...(11.14)