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 said:
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!