formatting based on the text

S

Sandra

I need to format several docs every day. They're programs written in Notepad
and any line that starts off with <! is a comment. My job is to copy the
text from Notepad and change all comment lines to be white text with a black
background. Is there some way for Word to do this automatically?

I know there are other programs besides Notepad but this is what I stuck
with doing so I can't change the process.

Thanks
 
J

Jonathan West

Sandra said:
I need to format several docs every day. They're programs written in
Notepad
and any line that starts off with <! is a comment. My job is to copy the
text from Notepad and change all comment lines to be white text with a
black
background. Is there some way for Word to do this automatically?

I know there are other programs besides Notepad but this is what I stuck
with doing so I can't change the process.

Thanks

Something like this should do the trick

Sub ReverseComments()
Dim oPara As Paragraph
For Each oPara In ActiveDocument.Paragraphs
If Left$(Trim$(oPara.Range.Text), 2) = "<!" Then
oPara.Range.Font.Color = wdColorWhite
oPara.Range.Shading.ForegroundPatternColor = wdColorBlack
End If
Next oPara
End Sub


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top