2017-06-19 1 views
0
私は削除して、ボタン

削除し、Wordの

でWord(ヘッダーとフッター)内の既存の形状を追加したい

に図形を追加しかし、私は、visibleプロパティを変更する図形を選択することはできません。

どうすればいいですか?私は単語の形の名前を理解することができません

あなたの助けをありがとう!

Sub LogoChangeVisible() 
' 
' Removes and adds the logo from Header and Footer 
' 
' 
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader 

Selection.HeaderFooter.Shapes("Picture from Header").Select 

If Selection.ShapeRange.Visible = msoTrue Then 
Selection.ShapeRange.Visible = msoFalse 
Selection.HeaderFooter.Shapes("Picture from Footer").Select 
Selection.ShapeRange.Visible = msoFalse 

ElseIf Selection.ShapeRange.Visible = msoFalse Then 
Selection.ShapeRange.Visible = msoTrue 
Selection.HeaderFooter.Shapes("Picture from Footer").Select 
Selection.ShapeRange.Visible = msoTrue 
End If 

ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument 

End Sub 

答えて

0

あなたはこのようなものを追加した場合:

For Each s In Selection.HeaderFooter.Shapes 
    Debug.Print s.Name 
Next 

を次に、あなたのデバッグウィンドウで名前を取得しますが。もう1つの方法は、名前を無視して数字を使用することです。

Selection.HeaderFooter.Shapes(1)... 
+0

これはどの形も見つかりませんでした。 jpg画像の場合は形状としてカウントされますか? –

+0

はい、シェイプとしてカウントされますが、インラインシェイプにすることもできます。これを試してください: Debug.Print ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InlineShapes.Count – Sam

関連する問題