Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autocorrect in VBA

Good day. I am trying to have inputs from a text box, when placed in a cell, trigger the autocorrect features. For example, textbox entry (tm) should apply to the cell as halfcase TM. Am having a devil of a time figuring this one out. Anyone trying to move from Santa's bad list to good list would get extra points!

Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Autocorrect in VBA

Jeff,

I've managed to get something working using SendKeys. The following code
puts the text in TextBox1 into cell A1 on Sheet1:

Private Sub CommandButton1_Click()
UserForm1.Hide
Worksheets("Sheet1").Range("A1").Value = ""
Worksheets("Sheet1").Activate
Worksheets("Sheet1").Range("A1").Activate
SendKeys "{F2}" & fQuoteString(TextBox1.Value) & "~"
End Sub

Private Function fQuoteString(sStringIn As String) As String
Dim sQuoteChars As String
Dim nChar As Long
Dim sCurrChar As String

sQuoteChars = "[]{}+^%~()"
fQuoteString = ""
For nChar = 1 To Len(sStringIn)
sCurrChar = Mid(sStringIn, nChar, 1)
If InStr(sQuoteChars, sCurrChar) 0 Then
fQuoteString = fQuoteString & "{" & sCurrChar & "}"
Else
fQuoteString = fQuoteString & sCurrChar
End If
Next nChar
End Function

(the fQuoteString function quotes special characters before passing them to
SendKeys).

Using SendKeys is a bit error-prone, to put it mildly. In particular, this
will only work if the code is run from Excel directly, instead of through
the VBA editor. I don't know if there's a better way...

Hope this helps,
Paul

"Jeff Fuller" wrote in message
...
Good day. I am trying to have inputs from a text box, when placed in a

cell, trigger the autocorrect features. For example, textbox entry (tm)
should apply to the cell as halfcase TM. Am having a devil of a time
figuring this one out. Anyone trying to move from Santa's bad list to good
list would get extra points!

Thank you.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autocorrect in VBA

Will try that.

Thanks for the reply and Merry Christmas
  #4   Report Post  
Posted to microsoft.public.excel.programming
COM COM is offline
external usenet poster
 
Posts: 40
Default Autocorrect in VBA

Not sure what functions of the autocorrect you are trying to implement

If you are just trying to change the case from lower to upper, you can use the before update features of the text box events, or if you have found a way to activate the autocorrect, then have the autocorrect run on the after update event. Be sure though to have a catch, that if the text in the text box is equal to the autocorrected text, not to update the text box. If the two texts are different, then go ahead and update the text box. If you watch your call stack, you'll see that the after update will be run once, then it will come back into the after update, once the code has assigned the autocorrected text


  #5   Report Post  
Posted to microsoft.public.excel.programming
COM COM is offline
external usenet poster
 
Posts: 40
Default Autocorrect in VBA

Also if you use the Microsoft Help/"Paperclip" You would find the following when searching "AutoCorrect Object

Contains Microsoft Excel AutoCorrect attributes (capitalization of names of days, correction of two initial capital letters, automatic correction list, and so on)

Using the AutoCorrect Objec

Use the AutoCorrect property to return the AutoCorrect object. The following example sets Microsoft Excel to correct words that begin with two initial capital letters

With Application.AutoCorrec
.TwoInitialCapitals = Tru
.ReplaceText = Tru
End Wit

You should be able to find more if you use the object browser or the AutoCorrect Object help page referenced above, and look at the properties and methods of the AutoCorrect object.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autocorrect WJason Excel Discussion (Misc queries) 3 September 27th 07 11:38 PM
Autocorrect James Silverton[_2_] Excel Discussion (Misc queries) 1 August 4th 07 03:34 PM
autocorrect notrace2004 Excel Discussion (Misc queries) 1 May 29th 06 08:28 AM
AutoCorrect reneabesmer Excel Worksheet Functions 1 April 19th 05 05:34 AM
AutoCorrect reneabesmer Excel Worksheet Functions 0 April 19th 05 04:48 AM


All times are GMT +1. The time now is 12:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"