sianfox 发表于 2019-6-20 23:29:35

随机出现两个点,并显示点的位置,然后用线段把两个点连接起来

在PPT中实现如下功能,应该怎么做啊?

在幻灯片里,点开始按钮后,随机出现两个点,并显示点的位置;显示继续,点一下继续,虚线线段把两个点连接起来

hajbl2002 发表于 2019-6-21 00:30:04

感觉可以用图表实现,散点图或者折线图?我是猜的呢。

wintertang 发表于 2019-6-21 00:44:02

能不能详细一些

helicopter 发表于 2019-6-21 01:25:40

求帮助啊,大神们帮看看

lining7510 发表于 2019-6-21 01:28:35

用VBA可以做,但你说显示位置,怎么显示位置?显示坐标?

haycinth 发表于 2019-6-21 01:41:25

就是坐标。

funwmy 发表于 2019-6-21 01:41:51

就 是 坐 标。

zhangdayon 发表于 2019-6-21 01:57:10

PPT里底层的位置都是用像素表示的,不同的显示器转换成厘米可能不一样

qzq888 发表于 2019-6-21 02:16:11

显示像素也行啊

liulin 发表于 2019-6-21 02:20:28

里边坑太多,做了一个小时才做出来



Private Sub CommandButton1_Click()

Dim MySlideIndex As Integer
Dim MySlide As Slide
Dim MaxWidth, MaxHeight As Integer
Dim PA, PB As Shape
Dim PAX, PAY, PBX, PBY As Integer

MySlideIndex = SlideShowWindows(1).View.Slide.SlideIndex
Set MySlide = ActivePresentation.Slides(MySlideIndex)

MaxWidth = ActivePresentation.PageSetup.SlideWidth
MaxHeight = ActivePresentation.PageSetup.SlideHeight

PAX = Int((MaxWidth * Rnd) + 1)
PAY = Int((MaxHeight * Rnd) + 1)
PBX = Int((MaxWidth * Rnd) + 1)
PBY = Int((MaxHeight * Rnd) + 1)
Label3.Caption = PAX
Label7.Caption = PAY
Label4.Caption = PBX
Label8.Caption = PBY

Set PA = MySlide.Shapes.AddShape(msoShapeOval, PAX, PAY, 2, 2)
Set PB = MySlide.Shapes.AddShape(msoShapeOval, PBX, PBY, 2, 2)


End Sub

Private Sub CommandButton2_Click()

Dim MySlideIndex As Integer
Dim MySlide As Slide
Dim MyLine As Shape
Dim X1, Y1, X2, Y2 As Integer

MySlideIndex = SlideShowWindows(1).View.Slide.SlideIndex
Set MySlide = ActivePresentation.Slides(MySlideIndex)

X1 = Label3.Caption
Y1 = Label7.Caption
X2 = Label4.Caption
Y2 = Label8.Caption

Set MyLine = MySlide.Shapes.AddLine(X1, Y1, X2, Y2)
MyLine.Line.DashStyle = msoLineSysDash

End Sub

Private Sub CommandButton3_Click()

Dim MySlideIndex As Integer
Dim MySlide As Slide

MySlideIndex = SlideShowWindows(1).View.Slide.SlideIndex
Set MySlide = ActivePresentation.Slides(MySlideIndex)

Label3.Caption = ""
Label7.Caption = ""
Label4.Caption = ""
Label8.Caption = ""

For i = MySlide.Shapes.Count To 1 Step -1
    If MySlide.Shapes(i).Type = 1 Or MySlide.Shapes(i).Type = 9 Then MySlide.Shapes(i).Delete
Next i

End Sub

复制代码
页: [1] 2
查看完整版本: 随机出现两个点,并显示点的位置,然后用线段把两个点连接起来