0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VBAで全オートシェイプをグループ化解除できなくなるまでグループ化解除する

Last updated at Posted at 2015-06-23

対象のエクセルの1枚目のシートに存在する全オートシェイプについて
グループ化解除できなくなるまでグループ化解除する。

Function ungroopAllMsoGroup()

  Dim grp_flg As Boolean
  Dim shp As Shape
  Dim mwbk As Workbook
  
  Set mwbk = ThisWorkbook

  grp_flg = True

  Do While grp_flg = True
    grp_flg = False
    
    For Each shp In mwbk.Sheets(1).Shapes
      If shp.Type = msoGroup Then
        shp.Ungroup
        grp_flg = True
      Else
      End If
    Next shp
  Loop

End Function

ループ処理に入った段階でグループ化フラグをfalseにしています。
ひとつでもグループ化されたオブジェクトがあればフラグをtrueにし、
次のループ処理でグループ化されたオブジェクトが残っているかを判定しています。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?