Insert logo macro

Posted on 2011-10-10
Last Modified: 2012-05-12

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

Question by:sbsbats
    LVL 23

    Accepted Solution

    See if subsituting this works

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

    Open in new window


    Author Comment

    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?

    Author Closing Comment

    cheers for your help

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Outlook Free & Paid Tools
    This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
    The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now