Results 1 to 7 of 7

Thread: Word Shapes

  1. #1

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    Word Shapes

    I am writing a vba macro to do several different things. One of which is to delete a defined shape out of a word document. Therein lies the problem. I have to identify the shape by dimension which should be all well and good, but some shapes are in a group of shapes and the dimensions dont match. So I was wondering, is there a way to have vba look at an image, determine if it is a shape and the go throught each individual image in the group?

    If anyone can help me on this I would be most appreciative.

    Thank You in advance.
    Last edited by safewithyou247; May 30th, 2006 at 08:27 AM.
    "A candle loses nothing by lighting another candle."

  2. #2

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    Re: Word Shapes

    Ok this is what I have so far. I need help in the places that I put comments.

    VB Code:
    1. Dim objWond As Shape
    2.     Dim vix As Integer
    3.     Dim vox As Integer
    4.     Dim i As Integer
    5.     Dim a As Integer
    6.     vox = ActiveDocument.Shapes.Count
    7.     i = 1
    8.     Do Until i = vox
    9.         'need if then statement to detemine if the shape is a group or not.
    10.         vix = ActiveDocument.Shapes(i).GroupItems.Count
    11.         a = 1
    12.         Do Until a = vix
    13.             With ActiveDocument.Shapes(i)
    14.                 If .GroupItems(a).height = 365 And .GroupItems(a).width = 404 Then
    15.                     'Need to be able to delete the shape in the group.  I tried .GroupItems(a).delete and it didn't work
    16.                 End If
    17.             End With
    18.             a = a + 1
    19.         Loop
    20.         'End if
    21.     i = i + 1
    22.     Loop
    Last edited by safewithyou247; May 30th, 2006 at 09:00 AM.
    "A candle loses nothing by lighting another candle."

  3. #3
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Word Shapes

    I have only used Wordart once, and I manipulated them by giving them names. The following is a piece of code I use to apply a dummy watermark to a document.
    Couldn't you do a similar thing, i.e. name each wordart you create ?
    That way you could delete/set them to blank at will.

    VB Code:
    1. If passForm.Name = "frmInvoice" Then
    2.             With objWord
    3.                 ' Page 1
    4.                 .ActiveDocument.Shapes("WordArt 6").Select
    5.                 .Selection.ShapeRange.TextEffect.Text = " "
    6.                 ' Page 2
    7.                 .ActiveDocument.Shapes("WordArt 8").Select
    8.                 .Selection.ShapeRange.TextEffect.Text = " "
    9.             End With
    10.         Else
    11.             If Invoiced = True Then
    12.                 ' Page 1
    13.                 .ActiveDocument.Shapes("WordArt 6").Select
    14.                 .Selection.ShapeRange.TextEffect.Text = "Reprint"
    15.                 ' Page 2
    16.                 .ActiveDocument.Shapes("WordArt 8").Select
    17.                 .Selection.ShapeRange.TextEffect.Text = "Reprint"
    18.             Else
    19.                 ' Page 1
    20.                 .ActiveDocument.Shapes("WordArt 6").Select
    21.                 .Selection.ShapeRange.TextEffect.Text = "Not Invoiced"
    22.                 ' Page 2
    23.                 .ActiveDocument.Shapes("WordArt 8").Select
    24.                 .Selection.ShapeRange.TextEffect.Text = "Not Invoiced"
    25.             End If
    26.         End If

  4. #4
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Word Shapes

    oops !

    Just realised I have read one thread and answered another ! ha ha !!! I need more coffee !

  5. #5
    New Member
    Join Date
    Nov 2006
    Posts
    13

    Re: Word Shapes

    To determine if a shape is a group test the TYPE property of the shape against the msoGroup constant (grange is a shape object):
    If grange.Type = msoGroup Then
    MsgBox "Group"
    End If

    Sorry I can't be much help on the other part. I'm having some trouble with methods related to grouped shapes. If I stumble onto a solution, I'll be happy to pass it along.

    SilentKnight

  6. #6
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Word Shapes

    Did you realise this thread is 6 months old ?
    I had to wonder what my input on it was when the email came through.

  7. #7
    New Member
    Join Date
    Nov 2006
    Posts
    13

    Re: Word Shapes

    It was late

Posting Permissions

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



Click Here to Expand Forum to Full Width