# MAcro- Where is it? Its here somewhere!



## Willot (Mar 28, 2006)

n new to this so im trying to muddle my way through.

I have the following code
Code:

ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddPicture(Filename:=PathOfFile _
, LinkToFile:=False, SaveWithDocument:=True).Select
* Selection.ShapeRange.Name = "WordPictureWatermark1"*
Selection.ShapeRange.PictureFormat.Brightness = 0.85
Selection.ShapeRange.PictureFormat.Contrast = 0.15
Selection.ShapeRange.LockAspectRatio = True
Selection.ShapeRange.Height = CentimetersToPoints(13.16)
Selection.ShapeRange.Width = CentimetersToPoints(17.55)
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapNone
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.Left = wdShapeCenter
Selection.ShapeRange.Top = wdShapeCenter
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

This puts a shape into the header called wordpicturewatermark1 right?

If it does I need to be able at a later date determine if this shaperange already exists because the user may need to change the watermark. I know how to delete it.
Code:

ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes("WordPictureWatermark1").Select
Selection.Delete
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

But how do I find out if the things exists in the first place!
Because if I try to delete when it isnt there in the first place it chucks a wobbley (and rightly so)
is there something like ActiveDocument.Header.Shapes("WordPictureWatermark1").Exists??

any help is greatly appreciated


----------



## s1dev (Jun 25, 2004)

You can catch the 'woobley':

on error goto woobleycatch
Selection.HeaderFooter.Shapes("WordPictureWatermark1").Select
goto shapefound
wobbleycatch:
msgbox "The shape doesn't exist!"
shapefound:
' turn off error catch
on error goto 0 

Or you can search the shapes collection:

shapeexists = false
for each shape in Selection.HeaderFooter.Shapes
if shape.name="WordPictureWatermark1" then
shapeexists = true
end if
next
if shapeexists then
selection.delete
end if


----------



## Willot (Mar 28, 2006)

Hey thanks 
the search works a treat


----------

