View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] paul.hobin@jus.gov.on.ca is offline
external usenet poster
 
Posts: 8
Default Auto-correct macro or VBA

Jack, I'm not certain I understand what you're trying to do. Your code uses
the AddReplacement method of the AutoCorrect object. I've never used the
AutoCorrect object in code so I'm not intimately familiar with the object and
its features (at least from a programming perspective), but what I believe
your code does is add to the list of strings that Excel is to replace when
the user types them into worksheet cells. If this code runs successfully
every time the user enters a U, S, M or E in a cell (NOT in your form) Excel
will change their entry to the word you've specified.

If you want these individual letters to automatically populate a control
like a TextBox, use the TextBox_Change event procedure, something like this:

Sub YourTextBoxName_Change

If YourTextBoxName = "S" Then
YourTextBoxName="Satisfactory"
ElseIf YourTextBoxName = "U" Then
YourTextBoxName="Unsatisfactory"
EndIf

End Sub

Just add as many "ElseIf"s as you need to accommodate all the letters you
want to provide automatic population for.



"Jack_Feeman" wrote:

I have created an Evaluation Form in Excel 2003. For expeditious handling and
ease of use, I created an auto-correct function to replace lets say "S" with
"Satisfactory", "U" with Unsatisfactory, etc. (see actual code below).
However, it does not go with the workbook so I assume VBA is the way to do
it. However, even my attempt in VBA does not produce the desired results
either (I must be doing something wrong). Please help me straighten out the
code. Thanks
Code extract:
Private Sub Workbook_Open()
Splash.Show
End Sub

Sub autocorrect()
'
' autocorrect Macro
' Macro recorded 9/5/2007 by Jack Feeman
'

'
Application.autocorrect.AddReplacement What:="U", Replacement:= _
"Unsatisfactory"
Application.autocorrect.AddReplacement What:="S", Replacement:= _
"Skill Needs Development"
Application.autocorrect.AddReplacement What:="M", Replacement:= _
"Meets Expectations"
Application.autocorrect.AddReplacement What:="E", Replacement:= _
"Exceeds Expectations"
With Application.autocorrect
.TwoInitialCapitals = True
.CorrectSentenceCap = True
.CapitalizeNamesOfDays = True
.CorrectCapsLock = True
.ReplaceText = True
.DisplayAutoCorrectOptions = True
End With
End Sub
" End code extract.
I see the splash displays all right when an user opens it but the
auto-correct sub doesn't work.

Thanks again
Jack