none
macro to check & highlight all tab position in word RRS feed

  • Question

  • I need a macro to highlight all the Tab posistion in the word document ( all the tabs are in Inches ).

    The MAcro should be able to highlight all the different alignment of the tabs ( left or right or decimal etc.....in the document.

    The Line of the text marked with the tabs can be highlighted or font colour can be changed to red to indicate that the line has some tab

     I have tried using the find & replace option but it is highlighting only after i specify the measurement. After the conversion of the pdf file to word doc, the Word file has randamly given tab at multiple location with multiple alignment & measurement. Hence the request
    . File is very hufe - 600 pages.....

    Sub tabssss()
    '
    ' tabssss Macro
    '
    '
    Selection.Find.ClearFormatting
    Selection.Find.ParagraphFormat.TabStops.ClearAll
    Selection.Find.ParagraphFormat.TabStops.Add Position:=InchesToPoints(0.12) _
    , Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.Find.Execute
    End Sub




    • Edited by ALI74 Saturday, January 19, 2013 5:27 AM
    Wednesday, January 2, 2013 12:12 PM

Answers

  • Does this do what you want?

    Sub FindTabs()
        Dim par As Paragraph
        For Each par In ActiveDocument.Paragraphs
            If Abs(par.TabStops(1).Position - InchesToPoints(0.12)) > 0.02 Then
                par.Range.Select
                MsgBox "Please fix the tab stop of this paragraph.", vbInformation
                Exit For
            End If
        Next par
    End Sub

    Again, if you're using centimeters as unit, change InchesToPoints to CentimetersToPoints.

    Regards, Hans Vogelaar

    • Marked as answer by ALI74 Friday, January 4, 2013 12:06 PM
    Wednesday, January 2, 2013 1:07 PM

All replies

  • Hi Ali,

    What unit are you using? If you use inches, try

    Sub FindIndent()
        Dim par As Paragraph
        For Each par In ActiveDocument.Paragraphs
            If Abs(par.LeftIndent - InchesToPoints(0.12)) > 0.02 Then
                par.Range.Select
                MsgBox "Please fix the indent of this paragraph.", vbInformation
                Exit For
            End If
        Next par
    End Sub

    If you're using centimeters, change InchesToPoints to CentimetersToPoints.

    Regards, Hans Vogelaar

    Wednesday, January 2, 2013 12:33 PM
  • Sir,

    I think i have not put my query right , The macro you have given is giving error message for para indent

    I need the macro to check for the indent  of the bulleted text

    for example :

    (a)           Rugged,  noise immune equipment;

    (b)           Modular plug-in construction,  allowing easy replacement or addition of units (e.  g.  input/output);

    (c)            Standard input/output connections and signal levels;

    In the above bulleted text I want to check whether the tab indent of the bullet is 0.12 ( ie: between the bullet and the text

    inconvience caused is regretted


    ALI

    Wednesday, January 2, 2013 12:56 PM
  • Does this do what you want?

    Sub FindTabs()
        Dim par As Paragraph
        For Each par In ActiveDocument.Paragraphs
            If Abs(par.TabStops(1).Position - InchesToPoints(0.12)) > 0.02 Then
                par.Range.Select
                MsgBox "Please fix the tab stop of this paragraph.", vbInformation
                Exit For
            End If
        Next par
    End Sub

    Again, if you're using centimeters as unit, change InchesToPoints to CentimetersToPoints.

    Regards, Hans Vogelaar

    • Marked as answer by ALI74 Friday, January 4, 2013 12:06 PM
    Wednesday, January 2, 2013 1:07 PM
  • Sir,

    The macro is still pointing at the tab position of the para  . it is not working with the bulleted text.

    Also I have removed the para indent... the macro is not giving error on the indent greater than 0.12

    The indent is in inches.

    The first line below is of 0.12 indent while the second line is of 0.26

    (a)           Rugged,  noise immune equipment;

    (b)           Modular plug-in construction,  allowing easy replacement or addition of units (e.  g.  input/output);


    ALI

    Wednesday, January 2, 2013 1:17 PM
  • Sorry, I'm out of ideas.

    Regards, Hans Vogelaar

    Wednesday, January 2, 2013 1:24 PM
  • Sir,

    The word document has two indent one for the paragraph & another for the bulleted text .

    there is a indent of 0.5" for the first line of the para which your macro is pointing at.

    After i have  tried with document where there is no para indent of 0.5 OR removed the para indent of 0.5 , the macro is working wonderful, it is pointing at the bulleted tab error if any 

    I am looking at a macro for all the bulleted text only . if the macro you have given, ignores all para indent of 0.5" ( ie: the first line of the para if any in the document )  , it will help me immensly .

     


    ALI

    Wednesday, January 2, 2013 1:43 PM
  • What happens if you use FirstLineIndent instead of LeftIndent?

    Sub FindIndent()
        Dim par As Paragraph
        For Each par In ActiveDocument.Paragraphs
            If Abs(par.FirstLineIndent - InchesToPoints(0.12)) > 0.02 Then
                par.Range.Select
                MsgBox "Please fix the indent of this paragraph.", vbInformation
                Exit For
            End If
        Next par
    End Sub

    Just grasping at straws...

    Regards, Hans Vogelaar

    Wednesday, January 2, 2013 2:03 PM
  • Sir,

    Even after using the abobe new macro ... the error is still pointing at the first line of the pAra . it is not going ahead...

    The Second macro which you have given is working fine as long as there is no indent of first line in the document.

    can the second macro be fine tuned to ignore the first lineindent of 0.5 or bypass it.....


    ALI


    • Edited by ALI74 Wednesday, January 2, 2013 2:19 PM
    Wednesday, January 2, 2013 2:18 PM
  • A last attempt:

    Sub FindTabs()
        Dim par As Paragraph
        For Each par In ActiveDocument.Paragraphs
            If Abs(par.TabStops(1).Position - par.FirstLineIndent - InchesToPoints(0.12)) > 0.02 Then
                par.Range.Select
                MsgBox "Please fix the tab stop of this paragraph.", vbInformation
                Exit For
            End If
        Next par
    End Sub


    Regards, Hans Vogelaar

    Wednesday, January 2, 2013 2:22 PM
  • Sir,

    The macro is not working... but i have thought of an idea...

    Will make a copy of the word file & remove all the first tab & will run the second macro which has run sucessfully....

    The macro will point the error in the file if any .

    I will  then modify the wrong tab in the orignal document.

    thank you very much... you have been a great help.................................


    ALI

    Wednesday, January 2, 2013 2:49 PM
  • OK, good luck!

    Regards, Hans Vogelaar

    • Marked as answer by ALI74 Wednesday, January 16, 2013 6:10 PM
    • Unmarked as answer by ALI74 Saturday, January 19, 2013 5:25 AM
    Wednesday, January 2, 2013 2:50 PM