Insert logo macro


I have a macro (thanks Graham) that inserts an image into a document - works well in Office 2010 (once I resaved the templates in this format) but the same code will not work for an Office97-2003 template or directly in a word 2003 template - I get the following error -
Run-Time Error 5843: One of the values passed to this method or
property is out of range.
Any idea what part of the code is not liking the 2003 format?

Sub InsertPictureShape()
Dim sh As Shape
With ActiveDocument
    ProtectType = .ProtectionType
    If Not (ProtectType = wdNoProtection) Then
    End If
  Set sh = .Shapes.AddPicture("C:\image\sbs.png", False, True, , , , Selection.Paragraphs(1).Range)
    sh.RelativeHorizontalPosition = wdRelativeHorizontalPositionLeftMarginArea
    sh.RelativeVerticalPosition = wdRelativeVerticalPositionTopMarginArea
    sh.Top = CentimetersToPoints(0.8)
    sh.Left = CentimetersToPoints(12.2)
    If Not (ProtectType = wdNoProtection) Then
      .Protect ProtectType, True
    End If
    End With
End Sub

Open in new window

Who is Participating?
JSRWilsonConnect With a Mentor Commented:
See if subsituting this works

Set sh = .Shapes.AddPicture(FileName:="C:\image\sbs.png", Anchor:=Selection.Paragraphs(1).Range)

Open in new window

sbsbatsAuthor Commented:
Thanks for that - the logo now inserts with no errors - the positioning of the logo is now a problem - using the absolute coordinates in the code above places the logo half off the page and chnaging the numbers dosn't seem to work to well.

Any idea of the posittioning code required?
sbsbatsAuthor Commented:
cheers for your help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.