Grouping shapes VBA word macro

爷,独闯天下 提交于 2019-12-12 04:07:41

问题


I'm trying to optimise my macro which allow me to ungroup all the shapes that are located in that active Page and if those shapes are already Ungrouped this macro will Group them

What I want to do is to modify this code to allow to group and Ungroup all in the Active page only not all te document . I'm a little noobi with VBA this is my code

Private Sub degroupage_Click()
    Dim mydocument As Document
    Set mydocument = ActiveDocument
    On Error Resume Next

    ActiveDocument.Unprotect   'enregistré manuellement
    Dim S As Shape, t As Shape

    For i = 0 To mydocument.Shapes.Item(1).GroupItems.Count
        For Each S In mydocument.Shapes
            If S.Type = msoGroup Then S.Ungroup 'Ungrouping all shapes in all the document :(

            If S.Selection.Ungroup = True Then 
                ActiveDocument.Selection.ShapeRange.Regroup  ' Problem here
        Next
    Next
End Sub

I need a quick help
the error is methode unfound for the Regroup and S.Selection.Ungoup

来源:https://stackoverflow.com/questions/46246261/grouping-shapes-vba-word-macro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!