Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    May 2009
    Thanked 0 Times in 0 Posts

    How to name a Word 2002 shape when it's inserted into a doc (code attached)

    I looked at some earlier posts about this subject but could not get the code to work in my case. This macro calls a Signature.bmp file on a drive. I need to give the inserted picture a name so that the rest of the code can format the shape.

    Word automatically assigns a name to the picture but I can't figure out how to then select that picture and work with it as the code runs. That's why a name needs assigned to the picture.

    Here's the code. When the macro was recorded, Word named the picture "Picture 11". And, that can vary every time the code runs. It's probably something very simple but I could use your help.

    Any code or thoughts would be very appreciated.


    Sub insertsig4cert()
    ' InsertSig4Cert Macro
    ' Macro recorded 10/17/2011

    With ActiveDocument.Shapes.AddPicture(Anchor:=Selection .Range, FileName:= _
    "H:\E-Signature-DO NOT DELETE\Signature.bmp", LinkToFile:=False, _
    .WrapFormat.Type = 3
    .ZOrder 5
    End With
    ActiveDocument.Shapes("Picture 11").Select
    Selection.ShapeRange.PictureFormat.TransparentBack ground = msoTrue
    Selection.ShapeRange.PictureFormat.TransparencyCol or = RGB(255, 255, 255)
    Selection.ShapeRange.Fill.Visible = msoFalse
    Selection.ShapeRange.ScaleWidth 0.4, msoFalse, msoScaleFromBottomRight
    Selection.ShapeRange.ScaleHeight 0.4, msoFalse, msoScaleFromBottomRight
    Selection.ShapeRange.IncrementLeft 279#
    Selection.ShapeRange.IncrementTop 610#
    ActiveDocument.Shapes.Range(Array("Group 2", "Group 5", "Picture 11")). _

    End Sub

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Jan 2001
    Melbourne, Victoria, Australia
    Thanked 143 Times in 136 Posts
    Try this version
    Dim aShp As Shape
      Set aShp = ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, FileName:= _
        "C:\Mysig.jpg", LinkToFile:=False, SaveWithDocument:=True)
      With aShp
        .Name = "MySig"
        .WrapFormat.Type = 3
        .ZOrder 5
        .PictureFormat.TransparentBackground = msoTrue
        .PictureFormat.TransparencyColor = RGB(255, 255, 255)
        .Fill.Visible = msoFalse
        .ScaleWidth 0.4, msoFalse, msoScaleFromBottomRight
        .ScaleHeight 0.4, msoFalse, msoScaleFromBottomRight
        .IncrementLeft 279#
        .IncrementTop 610#
      End With
    Last edited by Andrew Lockton; 2011-10-25 at 18:17.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #3
    Star Lounger
    Join Date
    May 2009
    Thanked 0 Times in 0 Posts
    Many thanks Andrew! I'll try out the code in. the morningCharlie

Tags for this Thread

Posting Permissions

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