Anybody,
I want to test a word document if its font is "Times New Roman"
if not I want to highlight those word/sentences that is not in Times new Roman...
Is this possible using Macro?
Thanks in advance...
Anybody,
I want to test a word document if its font is "Times New Roman"
if not I want to highlight those word/sentences that is not in Times new Roman...
Is this possible using Macro?
Thanks in advance...
Hi Psyclops
Welcome to VBAX.
[vba]
Option Explicit
Sub HighlightNonFont()
Dim w As Object
For Each w In ActiveDocument.Words
If w.Font.Name <> "Times New Roman" Then
w.HighlightColorIndex = wdRed
End If
Next
End Sub
[/vba]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Hi Malcom. If I may gently suggest...for newbies it would be better to put put full code (and...ahem...Option Explicit) in your posts. Just plunking that code into a procedure will not do much....I know....I just tried.
Amended as requested.
Thanks Gerry.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Wheeew...I was worried you may take that as intrusive.
Thanks to all of you mdmackillkop and fumei for the quick response...
I really appreciate your help and I'll try it now...
Hi ,
Just a follow-up
Do you think in this code whitespaces are also included to be highlight if its font is not in times new roman...
Thanks again...
[VBA]
Option Explicit
Sub HighlightNonFont()
Dim w As Object
For Each w In ActiveDocument.Words
If w.Font.Name <> "Times New Roman" Then
w.HighlightColorIndex = wdRed
End If
Next
End Sub
[/VBA]
Hi Psyclops
Try "Sentences" instead of "Words" (untested)
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Hi MD,
I have tried using "Sentences" instead of "Words" and the results is almost the same...
I think the problem is the whitespaces inside the table...Is there any possible solutions to this...
Why are you trying to do this?
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Hi MD,
I want to automatically verify if a set of documents is correct based on specified format before uploading it as HTML because sometimes when it is
uploaded as HTML file some of properties have been change if you pre-format.
I'm trying to check those font used in the entire document and if not i should highlight those fonts but when a font is inside the table, a whitespace, and not in Times New Roman it cannot highlight this portion....
Can you not simply select the table and apply TNR to the whole of the text.
If you're using mixed fonts, you should consider using styles, but that's another story!
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Hehehehehe.
Hmmmmmmmmmmmmm..........Styles? Whataconcept.
Happy to hand over to the Expert now!
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'