CDR VBA鼠标选择

    Dim x As Double, y As Double, Shift As Long, b As Boolean, doc As Document
    Dim sel1 As Shape, sel2 As Shape, s1 As Shape, s2 As Shape
    
    Set doc = ActiveDocument
    
    b = False
    While Not b
        b = doc.GetUserClick(x, y, Shift, 10, False, cdrCursorWinCross)
        Set sel1 = doc.ActivePage.SelectShapesAtPoint(x, y, False)
        If sel1.Shapes.Count > 0 Then
            Set s1 = sel1.Shapes.Last
            doc.ClearSelection
            s1.AddToSelection
        End If
        
        b = doc.GetUserClick(x, y, Shift, 10, False, cdrCursorWinCross)
        Set sel2 = doc.ActivePage.SelectShapesAtPoint(x, y, False)
        If sel2.Shapes.Count > 0 Then
            Set s2 = sel2.Shapes.Last
            doc.ClearSelection
            s2.AddToSelection
        End If
        
        s1.AlignToShape cdrAlignBottom, s2
        s1.AlignToShape cdrAlignRight, s2
    Wend

  

posted @ 2016-11-26 22:10  存心影子  阅读(1414)  评论(0编辑  收藏  举报