2017-06-19 43 views
0

我想刪除,並在Word(頁眉和頁腳)一個按鈕刪除,並在Word

添加現有形狀添加形狀,但我不能選擇形狀改變,可見屬性。

我該怎麼做?我無法弄清Word中形狀的名稱

感謝您的幫助!

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 

然後你會得到你的調試窗口的名稱。另一種方法是忽略名稱並用數字代替:

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

它沒有找到任何形狀。如果它是一張jpg圖片,它會算作一個形狀嗎? –

+0

是的,它算作一個形狀,但它也可以是內聯形狀。試試這個: Debug.Print ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InlineShapes.Count – Sam