• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

Insert logo macro

Hello,

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
      .Unprotect
    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

0
sbsbats
Asked:
sbsbats
  • 2
1 Solution
 
JSRWilsonCommented:
See if subsituting this works


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

Open in new window

0
 
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?
0
 
sbsbatsAuthor Commented:
cheers for your help
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now