Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

formatting based on the text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sandra - 24 Mar 2005 21:44 GMT
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
Jonathan West - 24 Mar 2005 23:22 GMT
>I need to format several docs every day. They're programs written in
>Notepad
[quoted text clipped - 7 lines]
>
> 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

Signature

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.