Click here to Skip to main content
16,016,301 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How I can send bracket using Sendkeys functions

I try this one
"%40" ALT+40 is ASCII value of "(" but it's not working.
please help me.
Posted

Use {(}" for "(" and {)} for ")"
 
Share this answer
 
Comments
Member 14949395 3-Oct-20 9:58am    
Very good. I couldn't find it anywhere how to send the normal brackets. This is the first place after searching the whole internet. Thx a lot
Eu adaptei uma funcao usada para a substituicao de letras acentuadas por letras sem acento, para que os caracteres especiais "[+^%~()]" fiquem entre chaves. Segue abaixo a funcao adaptada.

------------------------------------------------------------------------
Function SubstituirCaractereEspecial(ByVal strTexto As String) As String
'Substitui os caracteres especiais "[+^%~()]" para permitir seus envios através da função Sendkeys.
'Obs.: para o envio desses carateres usando Sendkeys, é necessário que eles estejam entre chaves {}. Ex.: {(} para o envio de abrir parênteses.

Dim lstrEspecial As String
Dim lstrSubstituto As String
Dim liPosicao, liControle As Integer

Application.Volatile
lstrEspecial = "[+^%~()]"
liPosicao = InStr(lstrEspecial, strTexto)
If strTexto <> "" Then
For liControle = 1 To Len(strTexto)
lstrLetra = Mid(strTexto, liControle, 1)
liPosicao = InStr(lstrEspecial, lstrLetra)
If liPosicao > 0 Then lstrLetra = "{" & Mid(lstrEspecial, liPosicao, 1) & "}"
lstrAlterada = lstrAlterada & lstrLetra
Next
strTexto = lstrAlterada
SubstituirCaractereEspecial = strTexto
Debug.Print strTexto
End If

End Function
 
Share this answer
 
Comments
OriginalGriff 13-May-22 9:56am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 9 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more!
Answering old questions can be seen as rep-point hunting, which is a form of site abuse - especially when your solution doesn't add anything particularly to the existing answer. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900