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

    How to group shapes into two separate groups (Word 2002)?

    I am writing code to insert a Filed Stamp (from AutoText) into a legal document and insert a person's signature to it (insertsig4filed macro). Then, it selects the inserted items and groups them so user can move all to a desired place on the page. This works fine except when similar code runs to add a Certified stamp and signature to the same document (insertsig4cert macro). The code for the second stamp breaks at:

    Code:
    ActiveDocument.Shapes.Range(Array("Rectangle 2", "Rectangle 3", _
            "Rectangle 4", "Rectangle 5" _
        , "MyFiledSig")).Select
        Selection.ShapeRange.Group.Select
    The desired result is for the Filed Stamp and the Certified Stamp to display on the same page.

    I would greatly appreciate any help so that both stamps can be added to one document. It's probably something very simple.

    Thanks,
    Charlie
    charlie6067

    Here's the entire code.

    Code:
    Sub insertsig4filed()
    '
    ' insertsig4filed Macro
    ' Macro recorded 10/24/2011 
    ' "&chr(10)&"This inserts the signature on the filed e stamp
    
    Dim aShp As Shape
      Set aShp = ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, FileName:= _
        "H:\E-Signature-DO NOT DELETE\Signature.bmp", LinkToFile:=False, SaveWithDocument:=True)
      With aShp
        .Name = "MyFiledSig"
        .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
     
     
    'With ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, FileName:= _
    '        "H:\E-Signature-DO NOT DELETE\Signature.bmp", LinkToFile:=False, _
    '        SaveWithDocument:=True)
    '        '.WrapFormat.Type = 3
    '        '.ZOrder 5
    '    End With
        ActiveDocument.Shapes("MyFiledSig").Select
        Selection.ShapeRange.PictureFormat.TransparentBackground = msoTrue
        Selection.ShapeRange.PictureFormat.TransparencyColor = RGB(255, 255, 255)
        Selection.ShapeRange.Fill.Visible = msoFalse
        Selection.ShapeRange.ScaleWidth 0.48, msoFalse, msoScaleFromBottomRight
        Selection.ShapeRange.ScaleHeight 0.48, msoFalse, msoScaleFromBottomRight
        Selection.ShapeRange.IncrementLeft 252#
        Selection.ShapeRange.IncrementTop 46.85
        ActiveDocument.Shapes.Range(Array("Rectangle 2", "Rectangle 3", _
            "Rectangle 4", "Rectangle 5" _
        , "MyFiledSig")).Select
        Selection.ShapeRange.Group.Select
     
    End Sub
     
    Sub insertsig4cert()
    '
    ' InsertSig4Cert Macro
    ' Macro recorded 10/17/2011 by 
    '
    Dim aShp As Shape
      Set aShp = ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, FileName:= _
        "H:\E-Signature-DO NOT DELETE\Signature.bmp", LinkToFile:=False, SaveWithDocument:=True)
      With aShp
        .Name = "MyCertSig"
        '.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
     
    'This is where code breaks if the first stamp is already in the document.
     ActiveDocument.Shapes.Range(Array("Group 2", "Group 5", "MyCertSig")). _
            Select
        Selection.ShapeRange.Group.Select
    
    End Sub
    Last edited by jscher2000; 2011-11-01 at 19:57. Reason: Added [code][/code] around code to aid readability.

  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 jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    When you say it breaks, what do you mean? Is the problem that Word doesn't find the objects listed in your array, or that it selects the "wrong" ones?

  4. #3
    Star Lounger
    Join Date
    May 2009
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It doesn't find the objects. The first time it does but not the second. If the macros are reversed, the cert stamp groups but the Filed stamp fails to group the shapes.Any suggestions?Many thanksCharlieCharlie 6067

  5. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,524
    Thanks
    3
    Thanked 143 Times in 136 Posts
    The group names you are looking for may not be in the document the second time you run the code. Since you don't explicitly name the groups, you are expecting Word to pick the objects that you mean rather than being explicit about what they are.

    Try naming the groups explicitly (when you have them selected) so that you can then call these groups later and know what their names are.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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