• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Click Event Copies Text as UpperCase to Clipboard

Hello forum,
I have a command button on a userform that copies a person's name (proper case, i.e., John Doe) to the clipboard so I can paste it into documents.
Is there a way to convert the text to upper case on the click event?

I've tried several things like adding:
txtSalesPer.Value = StrConv(txtSalesPer.Value, vbUpperCase)
or
txtSalesPer.Text = UCase(txtSalesPer.Text)
to the code below, but no luck

Code:
'Copy Button - Salesperson
Private Sub cmbCopySalesPer_Click()
With txtSalesPer
.SelStart = 0
.SelLength = .TextLength
.Copy
End With
End Sub

Thank you in advance!
 
I tried...
Code:
'Copy Button - Salesperson
Private Sub cmbCopySalesPer_Click()
txtSalesPer.Text = UCase(txtSalesPer.Text)
With txtSalesPer
.SelStart = 0
.SelLength = .TextLength
.Copy
End With
End Sub

I tried:
Code:
'Copy Button - Salesperson
Private Sub cmbCopySalesPer_Click()
txtSalesPer.Value = UCase(txtSalesPer.Value)
With txtSalesPer
.SelStart = 0
.SelLength = .TextLength
.Copy
End With
End Sub

I tried:
Code:
'Copy Button - Salesperson
Private Sub cmbCopySalesPer_Click()
txtSalesPer.Value = StrConv(txtSalesPer.Value, vbUpperCase)
With txtSalesPer
.SelStart = 0
.SelLength = .TextLength
.Copy
End With
End Sub

I tried:
Code:
'Copy Button - Salesperson
Private Sub cmbCopySalesPer_Click()
txtSalesPer.Text = StrConv(txtSalesPer.Text, vbUpperCase)
With txtSalesPer
.SelStart = 0
.SelLength = .TextLength
.Copy
End With
End Sub
 
Cool, but that's not what I'm looking for. I want to keep the text on the userform as proper case. I have a document that requires caps. So, I want to convert the proper to upper when I copy the salesperson's name to the clipboard.
 
As post #6 is nothing but a question, as any Excel forum is not a mind readers forum …​
 
Your comment is hurtful and it saddens me. Perhaps there is a misunderstanding in our communication. Regardless, that is a rude comment and I've done nothing to deserve it.
 
Yodelayheewho
Your I have a command button on a userform that copies a person's name (proper case, i.e., John Doe) to the clipboard so I can paste it into documents.
Have You tried to search - how to copy something to the clipboard? ... it's a bit different than Your sample codes.
Your Is there a way to convert the text to upper case on the click event?
Yes, there is ( with UCase )... You should convert only pure value.
You've tried to convert Your form (which should keep untouched).
>>>
Could You eg paste a (converted) person's name to specific textbox to Your form and after that basic Ctrl+C >>> Ctrl+V into documents?
 
Hello vtlem,
Have You tried to search - how to copy something to the clipboard? Initially, that is what I did, I searched and found the code above. It works perfect for copying the textbox contents to the clipboard. I only ran into problems when I added the codeline to convert the text to uppercase.

Your Is there a way to convert the text to upper case on the click event? Yes, there is ( with UCase )... You should convert only pure value. If I understand you correctly, I need to insert this codeline?
txtSalesPer.Value = UCase(txtSalesPer.Value)


I appreciate your response.
 
Yodelayheewho
Your Initially, that is what ... as I wrote, I found something else
Your If I understand you correctly, ... You understood something ... but I even tried to write something else (which should keep untouched).
 
Back
Top