R
robert.hatcher
I write a little VBA for excel and sometimes I want to print out the
code and have comment lines print in their green color. However
printing from VBA results in no color . I paste into word and print
from there but the font color doesnt transfer. I was trying to write
code that looks for the ' selects the rest of the line and changes the
color, cycling through the entire document. Im having two problems
1. I can get the the code to find the ', it seems to find stuff at
random
2. I need help selecting "to the end of the line" I am selecting the
entire line with:
(.Expand Unit:=wdLine
thanks in advance
Robert
Sub ColorVBA()
Dim i
For Each i In ActiveDocument.Characters
i = "'"
Selection.Find.ClearFormatting
With Selection.Find
.Text = i
'.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
.Expand Unit:=wdLine
.Font.Color = wdColorGreen
End With
Next i
End Sub
code and have comment lines print in their green color. However
printing from VBA results in no color . I paste into word and print
from there but the font color doesnt transfer. I was trying to write
code that looks for the ' selects the rest of the line and changes the
color, cycling through the entire document. Im having two problems
1. I can get the the code to find the ', it seems to find stuff at
random
2. I need help selecting "to the end of the line" I am selecting the
entire line with:
(.Expand Unit:=wdLine
thanks in advance
Robert
Sub ColorVBA()
Dim i
For Each i In ActiveDocument.Characters
i = "'"
Selection.Find.ClearFormatting
With Selection.Find
.Text = i
'.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
.Expand Unit:=wdLine
.Font.Color = wdColorGreen
End With
Next i
End Sub