Link to home
Start Free TrialLog in
Avatar of Dov_B
Dov_B

asked on

how do I get the index of a particular shape in a collection of activedocument.shapes MS Word VBA

how do I get the index of a particular shape in a collection of activedocument.shapes MS Word VBA
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

How do you define the particular shape, i.e. what information about the shape are you starting with?
Avatar of Dov_B
Dov_B

ASKER

well in  the solution you gave me an hour ago
you wrote the following code
Sub AddSmallTransparentCaption()
    Dim sh As Shape
    Dim tb As Shape
    Dim s As Integer

    s = 1
    
    Set sh = ActiveDocument.Shapes(s)
    sh.Select
    Selection.InsertCaption "Figure", , , wdCaptionPositionBelow
    
    Set tb = ActiveDocument.Shapes(s + 1)
    With tb
        .TextFrame.TextRange.Font.Size = 6
        .Fill.Transparency = 1
        .TextFrame.AutoSize = True 'doesn't seem to work
    End With
End Sub

Open in new window

so I wanted to know how I could add captions to pre existing shapes in my old document by selecting them and running a macro but I won't Be able to reference the caption because I won't know its index in the collection
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dov_B

ASKER

Dear GrahamSkan I am a teacher and an amateur self taught programmer I am in the middle of making a library of free material for elementary students with learning disabilities. It is only possible because of the many answers you have given me! May you be blessed with everything GOOD!