042471 ランダム
 HOME | DIARY | PROFILE 【フォローする】 【ログイン】

在宅仕事日記

在宅仕事日記

【毎日開催】
15記事にいいね!で1ポイント
10秒滞在
いいね! --/--
おめでとうございます!
ミッションを達成しました。
※「ポイントを獲得する」ボタンを押すと広告が表示されます。
x

PR

Keyword Search

▼キーワード検索

Calendar

Profile

tanpopo3416

tanpopo3416

Favorite Blog

SUGAR CANE INDIGO☆BLUEさん
気楽に行こう♪ モア☆さん
ビミョウな隣人 はるぎぃさん
SOHO翻訳者の仕事部屋 まな!さん

Comments

tanpopo3416@ Re:Excel VBA グループ解除、再グループ化(07/20) 「VBA オートシェイプのグループを再帰的…
jone@ Re:Excel VBA グループ解除、再グループ化(07/20) ワークシート版も考えてみました。 図A,…
tanpopo3416@ Re[1]:Excel VBA グループ解除、再グループ化(07/20) jone さんへ 「オートシェイプをコピーし…
tanpopo3416@ Re:Excel VBA グループ解除、再グループ化(07/20) コメントありがとうございます。 >図…
jone@ Re:Excel VBA グループ解除、再グループ化(07/20) 私も挑戦していました。久しぶりのプログ…

Freepage List

Oct 23, 2023
XML
カテゴリ:Word VBA
追記:2023年12月4日
マクロの記事は下記のサイトで書くことにしました。
Word VBA/マクロ 備忘録


Sub 本文、ヘッダーフッター、オートシェイプ置換()
    
    Dim mae As String
    Dim ato As String
    Dim sec As Section
    Dim hdr As HeaderFooter
    Dim ftr As HeaderFooter
    Dim rng As Range
    Dim shp As Shape, gShp As Shape, inlShp As InlineShape, satNode As SmartArtNode
    mae = "■" '検索するキーワード
    ato = "□" '検索後のキーワード
    
    '本文置換
'    On Error Resume Next
    Set rng = ActiveDocument.Range(0, 0)
    With rng.Find
        .Text = mae
        .Replacement.Text = ato
        .Execute Replace:=wdReplaceAll
    End With
   
    'ヘッダーフッター内置換
    For Each sec In ActiveDocument.Sections
        For Each hdr In sec.Headers
            With hdr.Range.Find
                .Text = mae
                .Replacement.Text = ato
                .Execute Replace:=wdReplaceAll
            End With
        Next
        
        For Each ftr In sec.Footers
            With ftr.Range.Find
                .Text = mae
                .Replacement.Text = ato
                .Execute Replace:=wdReplaceAll
            End With
        Next
    Next
    
    'オートシェイプ内置換
    For Each shp In ActiveDocument.Shapes
        If shp.Type = msoGroup Then
           For Each gShp In shp.GroupItems
                If gShp.TextFrame.HasText Then
                    With gShp.TextFrame.TextRange.Find
                        .Text = mae
                        .Replacement.Text = ato
                        .Execute Replace:=wdReplaceAll
                    End With
                End If
            Next
        End If
        
        If shp.TextFrame.HasText Then
            Set rng = shp.TextFrame.TextRange
            With rng.Find
                .Text = mae
                .Replacement.Text = ato
                .Execute Replace:=wdReplaceAll
            End With
        End If
    Next
End Sub





お気に入りの記事を「いいね!」で応援しよう

Last updated  Dec 4, 2023 10:23:16 AM
コメント(0) | コメントを書く



© Rakuten Group, Inc.
X