资源预览内容
第1页 / 共5页
第2页 / 共5页
第3页 / 共5页
第4页 / 共5页
第5页 / 共5页
亲,该文档总共5页全部预览完了,如果喜欢就下载吧!
资源描述
实现在实现在 PPTPPT 演示过程中,用鼠标拖动图片演示过程中,用鼠标拖动图片1新建一个 ppt 空白文档。2点击菜单: “工具宏宏” ,出现对话框。3对话框中“宏名”写:drop其他也可以 ,再点“创建” ,就进入代码模式。4 “Sub drop()End Sub” ,类似的三句全删掉。把下面的代码全拷贝进去。Option ExplicitDeclare Function GetKeyState Lib user32 (ByVal nVirtKey As Long) As IntegerPrivate Declare Function WindowFromPoint Lib user32 (ByVal xPoint As Long, ByVal yPointAs Long) As LongPrivate Declare Function GetWindowRect Lib user32 (ByVal hwnd As Long, lpRect As RECT)As LongPrivate Declare Function GetCursorPos Lib user32 (lpPoint As PointAPI) As LongPrivate Declare Function SetCursorPos Lib user32 (ByVal x As Long, ByVal y As Long) AsLongPublic Declare Function MonitorFromPoint Lib user32.dll (ByVal x As Long, ByVal y As Long,ByVal dwFlags As Long) As LongPrivate Declare Function GetSystemMetrics Lib user32 (ByVal nIndex As Long) As Long学习文档 仅供参考Private Const SM_SCREENX = 0Private Const SM_SCREENY = 1Private Const sigProc = Drag & DropPublic Const VK_SHIFT = &H10Public Const VK_CTRL = &H11Public Const VK_ALT = &H12Private Type PointAPIx As Longy As LongEnd TypePublic Type RECTLeft As LongTop As LongRight As LongBottom As LongEnd TypePublic mPoint As PointAPI, dPoint As PointAPI学习文档 仅供参考Public ActiveShape As ShapeDim dragMode As BooleanDim dx As Double, dy As DoubleSub DragandDrop(sh As Shape)dragMode = Not dragModeIf dragMode Then Drag shEnd SubPrivate Sub Drag(sh As Shape)Dim i As Integer, sx As Integer, sy As IntegerDim mWnd As Long, WR As RECTdx = GetSystemMetrics(SM_SCREENX): dPoint.x = dxdy = GetSystemMetrics(SM_SCREENY): dPoint.y = dyGetCursorPos mPoint学习文档 仅供参考mWnd = WindowFromPoint(mPoint.x, mPoint.y)GetWindowRect mWnd, WREnd WithIf dx dy Thensx = sx + (dx - dy) * ActivePresentation.PageSetup.SlideWidth / 2dx = dyEnd IfIf dy dx Thensy = sy + (dy - dx) * ActivePresentation.PageSetup.SlideHeight / 2dy = dxEnd IfWhile dragModeGetCursorPos mPoint学习文档 仅供参考sh.Left = (mPoint.x - sx) / dx - sh.Width / 2sh.Top = (mPoint.y - sy) / dy - sh.Height / 2DoEventsi = i + 1: If i 2000 Then dragMode = False: Exit SubWendEnd Sub5点击保存后,关闭代码模式,回到 ppt 设计页面。在你需要拖动的图片上点右键,选择“动作设置单击鼠标运行宏确定” 。然后就看效果吧。学习文档 仅供参考
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号