千家信息网

ppt如何做拖动互动

发表于:2024-11-11 作者:千家信息网编辑
千家信息网最后更新 2024年11月11日,这篇文章主要为大家展示了"ppt如何做拖动互动",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"ppt如何做拖动互动"这篇文章吧。一、普通视图模式在普通视图模
千家信息网最后更新 2024年11月11日ppt如何做拖动互动

这篇文章主要为大家展示了"ppt如何做拖动互动",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"ppt如何做拖动互动"这篇文章吧。

一、普通视图模式

在普通视图模式(不是全屏模式)下,即在编辑状态下,自然能实现图片的拖动功能。

优点:简单易行。

缺点:1.窗口较小,可视性不好;2.自定义动画效果无法实现。

二、宏

建议将宏的安全级别设置为低。

1、新建一个ppt空白文档。

2、点击菜单:"工具--宏--宏",出现对话框。

3、对话框中"宏名"随意写个,比如:move,再点"创建",就进入代码模式。

4、删去所有的代码,把下面的代码全拷贝进去。

Option ExplicitDeclare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As IntegerPrivate Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As 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) As LongPublic 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 LongPrivate Const SM_SCREENX = 0Private Const SM_SCREENY = 1Private Const sigProc = "Drag & Drop"Public Const VK_SHIFT = &H10Public Const VK_CTRL = &H11Public Const VK_ALT = &H12Private Type PointAPI    x As Long    y As LongEnd TypePublic Type RECT    Left As Long    Top As Long    Right As Long    Bottom As LongEnd TypePublic mPoint As PointAPI, dPoint As PointAPIPublic 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 mPointWith ActivePresentation.SlideShowWindow    mWnd = WindowFromPoint(mPoint.x, mPoint.y)    GetWindowRect mWnd, WR    sx = WR.Left    sy = WR.Top    dx = (WR.Right - WR.Left) / ActivePresentation.PageSetup.SlideWidth    dy = (WR.Bottom - WR.Top) / ActivePresentation.PageSetup.SlideHeightEnd WithIf dx > dy Then    sx = sx + (dx - dy) * ActivePresentation.PageSetup.SlideWidth / 2    dx = dyEnd IfIf dy > dx Then    sy = sy + (dy - dx) * ActivePresentation.PageSetup.SlideHeight / 2    dy = dxEnd IfWhile dragMode    GetCursorPos mPoint    sh.Left = (mPoint.x - sx) / dx - sh.Width / 2    sh.Top = (mPoint.y - sy) / dy - sh.Height / 2    DoEvents    i = i + 1: If i > 2000 Then dragMode = False: Exit SubWendEnd Sub

5、点击保存后,关闭代码模式,回到ppt设计页面。在你需要拖动的图片上点右键,选择"动作设置--单击鼠标--运行宏--确定"。

6、放映幻灯片,看看效果吧。

优点:可视性强。

缺点:对于PPT新手来说不易操作。

以上是"ppt如何做拖动互动"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

0