View Full Version : Macro to Highlight All Tabs in Word Document
shaukat74
01-18-2013, 10:42 AM
Hi,
I need a macro to highlight all the Tab position in the word document ( all the tabs are in Inches ).
The MAcro should be able to highlight all the alignment of the tabs in the document whether it is left or right or decimal etc......
The Line having the tab needs to be highlight to show the presence of tab
or
the text can be coloured RED
gmaxey
01-18-2013, 01:00 PM
What have you tried? Show your existing code.
shaukat74
01-18-2013, 10:15 PM
Hi,
There is no macro for the same . 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.....
Below is the find & replace tab macro ... but it is very crude. I have recorded the same
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
Paul_Hossler
01-19-2013, 07:08 AM
I'm not sure why the fact that the tabs are is inches would affect what you want to do
You can just use "^t" in the .Find and "^&" in the .Replace
I just recorded an admittedly inefficient macro ...
Option Explicit
Sub Macro2()
'
' Macro2 Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = True
With Selection.Find
.Text = "^t"
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Paul
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.