【发布时间】:2020-07-18 20:56:23
【问题描述】:
我正在让 label1 在 powerpoint 中用鼠标移动。 但我得到用户定义类型未定义错误。
代码:
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Type POINTAPI
left As Long
top As Long
End Type
Dim Xoff, Yoff As Long
Dim dragstate As Boolean
Private Sub Label1_Click()
End Sub
Private Sub Label1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
dragstate = True
Xoff = X
Yoff = Y
End Sub
Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If dragstate = True Then
With Label1
Dim mouse As POINTAPI
GetCursorPos mouse
.top = mouse.top / 2 - Xoff
.left = mouse.left / 2 - Yoff
End With
End If
End Sub
Private Sub Label1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
dragstate = False
ActivePresentation.SlidesShowWindows.View.GotoSlide ActivePresentation.SlidesShowWindow.View.CurrentShowPosition
End Sub
enter image description here 有人可以帮我吗?
【问题讨论】:
-
您在 32 位应用程序中工作吗?如果没有,请尝试
Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long。 -
我在 32 位工作
-
试试
Dim Xoff As Long, Yoff As Long。否则,Xoff被声明为As Variant。 -
将 .SlidesShowWindows 的每个实例替换为 .SlideShowWindow 并将 Label1 替换为 With ActivePresentation.Slides(1).Shapes("Label1") 或其他引用 Label1 形状的方式。
-
好的..我会试试的
标签: vba types powerpoint defined user-defined