Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Location
    St Georges du Bois, Pays de la Loire
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Deleting graphics in headers en masse (Word 97/SR2)

    Our company has just been taken over and I need to delete the old logo in aprox 1000 document headers.

    I am using the following - in an open file/close file loop to delete the graphics:

    'First unprotect the Form
    ActiveDocument.Unprotect Password:="xxxx"


    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
    ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View.Type = wdOutlineView Or ActiveWindow.ActivePane.View.Type _
    = wdMasterView Then
    ActiveWindow.ActivePane.View.Type = wdPageView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.HeaderFooter.Shapes("Picture 1").Select
    Selection.ShapeRange.delete
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument


    'Then reprotect the form
    ActiveDocument.Protect Password:="xxxx", NoReset:=True, Type:= _
    wdAllowOnlyFormFields

    But this will only delete the graphic in the first header.

    Would someone be kind to enough to amend the code for me so that it will delete all graphics in all headers?

    The graphics are all floating tiffs or gifs.

    Many thanks,

    David

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Deleting graphics in headers en masse (Word 97/SR2)

    Try this. It does not care whether the shape in the header is a picture or something else, so if you have other shapes in your headers, you might need to add another check before deleting.
    <pre>Sub StripHeaderShapes()
    Dim sec As Section, hdr As HeaderFooter, intShapes As Integer
    ' March through every section in the active document
    For Each sec In ActiveDocument.Sections
    ' March through every header in every section
    For Each hdr In sec.Headers
    ' Check for shape objects; could be more sensitive
    If hdr.Shapes.Count > 0 Then
    ' Delete all the shape objects
    For intShapes = hdr.Shapes.Count To 1 Step -1
    hdr.Shapes(intShapes).Delete
    Next
    End If
    Next
    Next
    End Sub</pre>


  3. #3
    Star Lounger
    Join Date
    Mar 2001
    Location
    St Georges du Bois, Pays de la Loire
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting graphics in headers en masse (Word 97/SR2)

    Thanks Jefferson - worked a treat.

    David

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •