+ Reply to Thread
Results 1 to 6 of 6

Watermark

  1. #1
    Steve
    Guest

    Watermark

    Using L Kittles code for a printable watermark....

    Option Explicit

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Target <> Range("A1") Then Exit Sub
    'On Error Resume Next
    If Range("A1").Value = "x" Then

    Dim Mud As Integer, Dum As Object
    Mud = 190 '200
    Application.ScreenUpdating = False
    Dim Page As Integer
    For Page = 1 To 1
    ActiveSheet.Shapes.AddTextEffect(msoTextEffect1, _
    "D R A F T", "Algerian", _
    30#, msoFalse, msoFalse, 155, 105#).Select
    With Selection
    .Name = "Dum"
    .ShapeRange.Fill.Visible = msoTrue
    .ShapeRange.Fill.Solid
    .ShapeRange.Fill.ForeColor.SchemeColor = 22
    .ShapeRange.Fill.Transparency = 0.5
    .ShapeRange.Line.Visible = msoFalse
    .ShapeRange.IncrementRotation -26.22
    .ShapeRange.IncrementTop Mud
    End With

    Next Page

    Application.ScreenUpdating = True

    ElseIf Range("A1").Value = "" Then
    WaterMarkerGone
    Exit Sub
    End If

    Range("A1").Select

    End Sub

    Sub WaterMarkerGone()
    Application.ScreenUpdating = False
    Dim Page As Integer
    Dim Dum As Shape
    For Page = 1 To 1
    On Error Resume Next
    ActiveSheet.Shapes("Dum").Select
    Selection.Cut
    Next Page
    Application.ScreenUpdating = True
    End Sub


    When I enter X in A1 I dont get the watermark. I have enter the code in
    This workbook module. I hae tried with the sheet protected and also without
    protection. Any ideas?
    Thanks in advance

  2. #2
    Lonnie M.
    Guest

    Re: Watermark

    Hi, I found a couple of things with the code you supplied and made
    changes.
    1) you were compairing the target object to the value of cell A1.
    2) when I copied this into my editor from his example and yours it
    brought in some dashes in the reserved words within word art portion of
    the code. i.e. .ShapeRange.Fill.ForeColor.Sch=AD-emeColor =3D 22. this may
    have affected your code in your editor as well.
    I may have also changed a few other minor things, but this is what
    worked for me:

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
    Range)

    Debug.Print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    Debug.Print Target.Address(False, False)
    Debug.Print Sh.Name
    If Target.Address(False, False) <> "A1" Then Exit Sub
    If Sh.Name <> "Sheet1" Then Exit Sub
    'On Error Resume Next
    If Range("A1").Value =3D "x" Then

    Dim Mud As Integer, Dum As Object
    Mud =3D 190 '200
    Application.ScreenUpdating =3D False

    ActiveSheet.Shapes.AddTextEffect(msoTextEffect1, _
    "D R A F T", "Algerian", _
    30#, msoFalse, msoFalse, 155, 105#).Select
    With Selection
    .Name =3D "Dum"
    .ShapeRange.Fill.Visible =3D msoTrue
    .ShapeRange.Fill.Solid
    .ShapeRange.Fill.ForeColor.SchemeColor =3D 22
    .ShapeRange.Fill.Transparency =3D 0.5
    .ShapeRange.Line.Visible =3D msoFalse
    .ShapeRange.IncrementRotation -26.22
    .ShapeRange.IncrementTop Mud
    End With

    Application.ScreenUpdating =3D True

    ElseIf Range("A1").Value =3D "" Then
    WaterMarkerGone
    Application.CutCopyMode =3D False
    Exit Sub
    End If

    Range("A1").Select

    End Sub


    Public Sub WaterMarkerGone()
    Application.ScreenUpdating =3D False
    Dim Page As Integer
    Dim Dum As Shape
    For Page =3D 1 To 1
    On Error Resume Next
    ActiveSheet.Shapes("Dum").Sele=ADct
    Selection.Cut
    Next Page
    Application.ScreenUpdating =3D True
    End Sub


    HTH--Lonnie M.


  3. #3
    Darrin Henshaw
    Guest

    Re: Watermark

    This works for me, however, VB is case sensitive, so if I put a capital
    X in A1 it won't work. However, it will work with a small x. Any other
    info you have?

    I would suggest adding Application.CutCopyMode = False, the end of your
    WaterMarkerGone. Makes it a bit more seamless.

    Darrin


    *** Sent via Developersdex http://www.developersdex.com ***

  4. #4
    Tim Williams
    Guest

    Re: Watermark

    Works for me with no changes.

    You're using a lower-case "x", right?

    --
    Tim Williams
    Palo Alto, CA


    "Steve" <[email protected]> wrote in message
    news:[email protected]...
    > Using L Kittles code for a printable watermark....
    >
    > Option Explicit
    >
    > Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As

    Range)
    > If Target <> Range("A1") Then Exit Sub
    > 'On Error Resume Next
    > If Range("A1").Value = "x" Then
    >
    > Dim Mud As Integer, Dum As Object
    > Mud = 190 '200
    > Application.ScreenUpdating = False
    > Dim Page As Integer
    > For Page = 1 To 1
    > ActiveSheet.Shapes.AddTextEffect(msoTextEffect1, _
    > "D R A F T", "Algerian", _
    > 30#, msoFalse, msoFalse, 155, 105#).Select
    > With Selection
    > .Name = "Dum"
    > .ShapeRange.Fill.Visible = msoTrue
    > .ShapeRange.Fill.Solid
    > .ShapeRange.Fill.ForeColor.SchemeColor = 22
    > .ShapeRange.Fill.Transparency = 0.5
    > .ShapeRange.Line.Visible = msoFalse
    > .ShapeRange.IncrementRotation -26.22
    > .ShapeRange.IncrementTop Mud
    > End With
    >
    > Next Page
    >
    > Application.ScreenUpdating = True
    >
    > ElseIf Range("A1").Value = "" Then
    > WaterMarkerGone
    > Exit Sub
    > End If
    >
    > Range("A1").Select
    >
    > End Sub
    >
    > Sub WaterMarkerGone()
    > Application.ScreenUpdating = False
    > Dim Page As Integer
    > Dim Dum As Shape
    > For Page = 1 To 1
    > On Error Resume Next
    > ActiveSheet.Shapes("Dum").Select
    > Selection.Cut
    > Next Page
    > Application.ScreenUpdating = True
    > End Sub
    >
    >
    > When I enter X in A1 I dont get the watermark. I have enter the code in
    > This workbook module. I hae tried with the sheet protected and also

    without
    > protection. Any ideas?
    > Thanks in advance




  5. #5
    Lonnie M.
    Guest

    Re: Watermark

    Disregard item 1--my eyes are a bit blurred, it is late in the day. I
    must have blended a couple of lines together when I was reading it. I
    would look to see if it inadvertently brought in the dashes when you
    pasted the code in--as described in item 2.


  6. #6
    Registered User
    Join Date
    04-25-2005
    Posts
    99

    Re: Watermark

    I've been working on a watermark macro off and on for a while now... from various sources I've created the following code. My problem, however, is that I cannot get the watermark to repeat on every page that has anything entered on it. I hope this can help you with your problem, and I hope someone can figure out how to solve my problem.

    All help is greatly appreciated.

    Sub Watermark()
    '**** This program inserts a watermark on the first page.****
    '* I am still trying to get it to put the watermark on to multiple pages. *

    Dim WMText As String, HBreak As Integer, VBreak As Integer
    Dim MSG As String, Title As String, PageCount As Integer, Page As Integer

    Title = "Watermark"
    MSG = "Enter Watermark Text: "
    WMText = InputBox(MSG, Title, "DRAFT")
    If WMText = "" Then End

    '*** Count the Total # of pages ****************************************
    HBreak = ActiveSheet.HPageBreaks.Count
    VBreak = ActiveSheet.VPageBreaks.Count
    PageCount = (HBreak + 1) * (VBreak + 1)
    '****************************************************************

    ActiveSheet.Activate
    Page = 0
    Do Until Page = PageCount

    ActiveSheet.Shapes.AddTextEffect(PresetTextEffect:=1, _
    Text:=WMText, FontName:="Arial Black", FontSize:=50, _
    FontBold:=False, FontItalic:=False, Left:=50, Top:=150).Select
    '* ' define the text dimensions
    With Selection.ShapeRange
    .ScaleHeight 1.23, False
    .ScaleWidth 1.6, False
    '* ' Solid or no color
    .Fill.Visible = True 'Hide any colors (if false)
    .Fill.Solid
    .Fill.ForeColor.SchemeColor = 22
    .Fill.Transparency = 0.75 'Semi-transparent
    '* ' Outline
    .Line.Weight = 1# 'Line weight outline (1.25 is darker)
    .Line.DashStyle = 1 'Use a solid line
    .Line.Style = 1 'use continuous, I am guessing
    .Line.Transparency = 0# 'Make the line semi-transparent
    .Line.Visible = True 'show the line
    .Line.ForeColor.SchemeColor = 22 'line color is blue
    .Line.BackColor.RGB = RGB(255, 255, 255) '
    .Height = 80 'expand the height of the text
    .Width = 350 'expand the width of the text
    End With
    Page = Page + 1
    ActiveWindow.LargeScroll down:=1
    Loop
    If PageCount > 1 Then
    MsgBox PageCount & " total pages."
    Else
    MsgBox PageCount & " page."
    End If

    End Sub



    Everything in orange has to do with my pagecount variable. I was trying to use pagecount in a way that would allow me to input the watermark on each page. I'm going cross-eyed after working on it so long!! Hope someone can figure it out.


    DejaVu
    Last edited by DejaVu; 05-03-2005 at 05:57 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1