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

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Deleting graphics in headers en masse (Word 97/SR2)

    • This topic has 2 replies, 2 voices, and was last updated 23 years ago.
    Author
    Topic
    #369695

    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

    Viewing 0 reply threads
    Author
    Replies
    • #582827

      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.

      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
    Viewing 0 reply threads
    Reply To: Deleting graphics in headers en masse (Word 97/SR2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: