Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Removing watermarks

    Some years ago, when using Office 2003, I developed a report template that included a logo and a "Draft" watermark in the header. The report was printed onto preprinted "bond" stationery (very expensive). To remove the logo and "Draft" watermark I, in conjunction with help from the forum, developed a macro to remove both the logo and the watermark (see attached). This has continued to work fine up until now. However, the macro has decided that it no longer wishes to be useful and has stopped removing the logo and watermark.

    Can anyone help?
    Attached Files Attached Files
    cheers

    Phil Carter

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Phil

    The docx file format can't contain macros. We need to see the code if we are to suggest fixes
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    Andrew
    The document is a hard copy of the code which is stored in a global template but used on the attached typical report
    Attached Files Attached Files
    cheers

    Phil Carter

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Interesting code. You permanently delete any floating shapes in the body of the document (thus potentially removing required content) but only toggle the visibility of the watermark. In the sample document you posted, the code appears to do what you wanted except if you run it a second time.

    However it is not particularly hard to imagine a scenario where the watermark is hidden and then another one is added over the top. Your code would then show one and hide the other so it appears nothing changed. Is there code in your template that adds a watermark (not just unhides it) which could be causing the issue you see.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    Andrew hi
    As I stated in the original post the report was designed to be printed o expensive bond paper when finalised. It contained a logo on the front page, hence the remove the logo "shape", and "DRAFT" watermarks. The intention of the code was to remove the logo and watermarks.
    Ideally we would like to remove the watermarks, which are only imbeded shapes
    cheers

    Phil Carter

  6. #6
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Phil

    Your code also turns off screen updates and doesn't turn it on again - this might be the problem too.

    Did the document you posted show the problem with the watermark remaining? The macro worked for me to hide the watermark but it did reveal it again when I ran the macro a second time. This is a rewrite which checks each of the headers for floating shapes. I guess it is possible that the watermark might have slipped into a footer so perhaps you also need a loop for that case too. I have changed to using ranges so screen updates should no longer be an issue.


    Code:
    Sub Final_Report()
      Dim Shp As Shape, aHF As HeaderFooter, bFinal As Boolean, iResponse As Integer
      
      'On Error Resume Next
      iResponse = MsgBox("Are you sure this is to be the final report?", _
              vbYesNo + vbCritical + vbDefaultButton2, "Final Report")
      bFinal = iResponse = vbYes
      
      If bFinal Then
        While ActiveDocument.Shapes.Count > 0
          ActiveDocument.Shapes(1).Delete
        Wend
        ActiveDocument.Bookmarks("bmkReportDate").Range.Text = Format(Date, "d MMMM yyyy")
      End If
      
      For Each aHF In ActiveDocument.Sections(1).Headers
        For Each Shp In aHF.Shapes
          If Shp.Type = msoTextEffect Then
            Shp.Visible = Not bFinal
          End If
        Next Shp
      Next aHF
    End Sub
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  7. The Following User Says Thank You to Andrew Lockton For This Useful Post:

    bonriki (2015-02-01)

  8. #7
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    Andrew thanks again
    Works a treat.
    Thought about the problem and seem to remember there was a reason for "hiding" the watermark but can't remember.
    cheers

    Phil Carter

Posting Permissions

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