【心灵驿站】
【校长信箱】
搜索
  数字校园
软件学习 首页 / 数字校园 -> 软件学习
 
 
如何实现在PPT播放时任意拖动图片至任何位置
发布时间:2015/11/17 12:58:59    浏览:1679次数

需要在PPT播放时任意拖动图片至任意位置,可使用VBA程序代码来实现,以下是可移动3张图片的代码。

1、插入图片控件,将图片设置为你想要的图片;

2、双击打开控件的代码,将原先的两行代码删除,复制下面的代码,注意要做一张图片,修改它对应的代码。

Dim X1, Y1, X2, Y2, X3, Y3 As Integer
Dim Down As Boolean
Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Not Down Then
X1 = X
Y1 = Y
Down = True
End If
End Sub
Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Down Then
Image1.Left = Image1.Left + X - X1
Image1.Top = Image1.Top + Y - Y1
X1 = X
Y1 = Y
End If
End Sub
Private Sub Image1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Down = False
SlideShowWindows(1).View.First
End Sub
Private Sub Image2_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Not Down Then
X2 = X
Y2 = Y
Down = True
End If
End Sub
Private Sub Image2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Down Then
Image2.Left = Image2.Left + X - X2
Image2.Top = Image2.Top + Y - Y2
X2 = X
Y2 = Y
End If
End Sub
Private Sub Image2_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Down = False
SlideShowWindows(1).View.First
End Sub
Private Sub Image3_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Not Down Then
X3 = X
Y3 = Y
Down = True
End If
End Sub
Private Sub Image3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Down Then
Image3.Left = Image3.Left + X - X3
Image3.Top = Image3.Top + Y - Y3
X3 = X
Y3 = Y
End If
End Sub
Private Sub Image3_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Down = False
SlideShowWindows(1).View.First
End Sub

如果需要拖动的图片不是三张,可对代码进行适当修改。

 
友情链接  
版权所有:江苏省淮阴中学开明分校
地址:淮安市清浦区西大街174号 电话:0517-83518004
技术支持:江苏苏软科技有限公司