2017-06-19 51 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