Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Query (Word 97, SR2)

    Can anyone suggest some vb-code in order that I can remove a piece of wordart from a header (i.e. a draft watermark) without removing the currently featuring graphic and table of text?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Query (Word 97, SR2)

    The following code will delete all WordArt shapes from the primary header of all sections. You can adapt it if you want to search other types of headers too (first page headers, odd/even pages headers), or if you want to search just one header.

    Dim sct As Section
    Dim shp As Shapes
    Dim n As Long
    Dim i As Long
    For Each sct In ActiveDocument.Sections
    Set shp = sct.Headers(wdHeaderFooterPrimary).Shapes
    n = shp.Count
    For i = n To 1 Step -1
    If Left(shp(i).Name, 7) = "WordArt" Then
    shp(i).Delete
    End If
    Next i
    Next sct

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Query (Word 97, SR2)

    How did the Word Art get into the header in the first place?

    The reason I ask is that I have a Macro that creates WordArt in headers for things like "Draft". I name the WordArt object when I create it, so that I can easily find it with a Macro when I want to remove it again. This approach saves a lot of messing about trying to distinguish objects by other characteristics.

    StuartR

  4. #4
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Query (Word 97, SR2)

    I have not studied the current "insert watermark" macro in great details (it was created by someone else) - would I be right in thinking that you are inserting an object through word and choosing MS Word Picture and creating the WordArt "DRAFT" in there?

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Query (Word 97, SR2)

    The relevant lines of code from my Macro are (something like...)
    <pre>Set shpWordArt = hdrThisHeader.Shapes.AddTextEffect(msoTextEffect1, _
    txtWaterMark, fntWaterMark, iFontSize, _
    msoFalse, msoFalse, 1, 1, _
    hdrThisHeader.Range)
    With shpWordArt
    <font color=448800>' Lots of other stuff here</font color=448800>
    .Name = "Watermark" & Str$(iHeaderNumber)
    End With
    </pre>

    StuartR

  6. #6
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Query (Word 97, SR2)

    Thanks for that - I've tried the code posted by HansV and that has done the job!

  7. #7
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Query (Word 97, SR2)

    Perfect - thank you!

Posting Permissions

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