Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Mar 2009
    Location
    India
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Hi,

    I've been trying to find if there is a way to Find and Highlight/comment missing figure and table captions. I have some documents that come for format correction to my team. There are times when writers have missed putting in captions for figures/tables. We just need to point these out to the writers so that they can insert captions where missing.
    ________
    Thanks,
    Shalini

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='Shalini' post='764277' date='09-Mar-2009 16:35']Hi,

    I've been trying to find if there is a way to Find and Highlight/comment missing figure and table captions. I have some documents that come for format correction to my team. There are times when writers have missed putting in captions for figures/tables. We just need to point these out to the writers so that they can insert captions where missing.[/quote]Hi Shalini,

    It's easy enough to write some code to loop through all shape objects in a document, and even to test whether those shapes have a caption following them. However, someone will presumably still need to decide whether the caption is appropriate. So what would you prefer to do:
    - use code to simply find and go to the next shape object?
    - something more complex?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    New Lounger
    Join Date
    Mar 2009
    Location
    India
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    Thanks for the quick reply, Paul.

    I would prefer just finding and highlighting missing caption. The documents are highly technical, and the person correcting the format may not have enough technical knowledge to judge the appropriateness in all cases.
    ________
    Thanks,
    Shalini

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='Shalini' post='764287' date='09-Mar-2009 17:26']Hi,
    Thanks for the quick reply, Paul.

    I would prefer just finding and highlighting missing caption. The documents are highly technical, and the person correcting the format may not have enough technical knowledge to judge the appropriateness in all cases.[/quote]
    Hi Shalini,

    Here's a macro that goes through all the 'inline' shapes in the active document, testing whether the text immediately following in the same paragraph consists of any of Word's standard caption prefixes. If the inline shapes lacks the caption prefix, the user is taken to that point and the macro exits.
    Code:
    Sub TestForCaptions()
    Dim iShp As InlineShape
    Dim TmpStr As String
    With ActiveDocument
      For Each iShp In .InlineShapes
    	TmpStr = iShp.Range.Paragraphs(1).Range.Text
    	If Mid(TmpStr, 3, 8) <> "Equation" Then
    	  If Mid(TmpStr, 3, 6) <> "Figure" Then
    		If Mid(TmpStr, 3, 5) <> "Table" Then
    		  iShp.Select
    		  Selection.GoTo What:=wdGoToObject
    		  Selection.MoveRight wdCharacter, 1
    		  Exit Sub
    		End If
    	  End If
    	End If
      Next
    End With
    End Sub
    As coded, the macro assumes the caption will be in the same paragraph as the object to which it refers. If you have non-standard captions, they can be catered for by adding more IF tests. If the captions are attached to the next paragraph, that too can be catered for. A similar approach could be taken with floating shapes, but they are more problematic since their anchors may have any relation to the caption paragraph.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    [quote name='macropod' post='764531' date='10-Mar-2009 05:48'][/quote]
    This will only work in English speaking countries, you could test if the word is in the CaptionLabels collection to make this work in other countries.

  6. #6
    New Lounger
    Join Date
    Mar 2009
    Location
    India
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for the help. I will try this and revert.
    Sorry for the delayed response though
    ________
    Thanks,
    Shalini

  7. #7
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    This will only work in English speaking countries, you could test if the word is in the CaptionLabels collection to make this work in other countries.
    Hi Stuart,

    OK. The following should be more robust.
    Code:
    Sub FindUncaptionedShape()
    Dim oCap As CaptionLabel
    Dim iShp As InlineShape
    Dim TmpRng As Range
    Dim TmpStr As String
    For Each oCap In CaptionLabels
      TmpStr = TmpStr & CaptionLabels(oCap) & " "
    Next
    With ActiveDocument
      For Each iShp In .InlineShapes
    	Set TmpRng = iShp.Range.Words.Last
    	With TmpRng
    	  Do While Len(.Text) = 1
    		.MoveEnd wdWord, 1
    		.MoveStart wdWord, 1
    	  Loop
    	  If InStr(TmpStr, .Text) = 0 Then
    		iShp.Select
    		Selection.GoTo What:=wdGoToObject
    		Selection.MoveRight wdCharacter, 1
    		Exit Sub
    	  End If
    	End With
      Next
    End With
    End Sub
    You'll see the code pushes all the caption types into a string for testing via Instr. In a document with many Inlineshapes, this should be faster that looping through the CaptionLabels collection every time an Inlineshape is found.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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