Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 01-09-2013, 06:42 PM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Testing for a printable character Windows XP Testing for a printable character Office 2007
Competent Performer
Testing for a printable character
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default

How about this? It turns any character in CharSet red and anything else green. In practice, it would skip them rather than turn them green.

Code:
Sub TestColorMacro()
Const MyName As String = "TestColorMacro"
Dim msg As String
msg = "Test the set of printable colors. Press Enter to continue or Cancel to abort."
Dim temp
temp = InputBox(msg, MyName, "OK")
If temp = "" Then Exit Sub

'Define the set of printable characters
Dim CharSet As String
CharSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" _
        & "abcdefghijklmnopqrstuvwxyz" _
        & "1234567890`~!@#$%^&*()-_=+[]{}\|;:,.<>/?" _
        & "'""" & Chr(145) & Chr(146) & Chr(147) & Chr(148)

Dim obChar As Range
For Each obChar In Selection.Characters
'  'Display the ASCII code
'  msg = obChar & "=" & Asc(obChar)
'  MsgBox msg
  'If the character is in the set, color it red.
  If InStr(CharSet, obChar) > 0 Then
    obChar.Font.Color = RGB(255, 0, 0)
  'Otherwise, color it green
  Else
    obChar.Font.Color = RGB(0, 255, 0)
  End If
Next obChar

End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Printable Area issues zaineyma Word 3 12-12-2012 09:11 AM
Testing for a printable character HELP/ADVICE NEEDED. Testing Excel Accessibility guidelines cmc89 Excel 1 03-29-2012 03:41 PM
Printable Entry Form eJames Excel 1 01-07-2010 09:50 AM
Making template that is not printable Askaleto Word 0 10-14-2009 11:45 AM
Defining Printable Areas OfficeUser00939 Word 5 06-29-2009 09:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft