View Single Post
 
Old 11-26-2014, 05:11 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub Demo()
Dim i As Long, Rng As Range, StrAltTxt As String
With ActiveDocument
  'Loop through all inlineshapes
  For i = 1 To .InlineShapes.Count
    'Point our range to the start of the document
    Set Rng = .Range(0, 0)
    With .InlineShapes(i)
      'Point the end our range to the start of the inlineshape
      Rng.End = .Range.Start
      With Rng
        'Look backwards for a Heading 4
        With .Find
          .Text = ""
          .ClearFormatting
          .Replacement.Text = ""
          .Replacement.ClearFormatting
          .Format = True
          .Style = wdStyleHeading4
          .Forward = False
          .Wrap = wdFindStop
          .Execute
        End With
        If .Find.Found = True Then
          'If we found a Heading 4, get the text, minus the paragraph end
          With .Duplicate
            .End = .End - 1
            StrAltTxt = .Text
          End With
        End If
      End With
      'Add the Heading 4 text as the Alternative Text
      .AlternativeText = StrAltTxt
      .Title = ""
    End With
  Next
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote