The textboxPhone has an input mask because users like to see their data entered neatly like (123) 456-7890.
But, often the users cuts a phone number like "123 456.7890 ext 12345" from an email and tries to paste it into text box.
Normally, a paste does not work because of the input mask stops it.
I "solved" that problem with the attached DoubleClick code, but I want control v to also work.
I tried On Change event, but that does not even get fired when the clipboard has non-numeric data. Does anybody have any ideas?
Private Sub Text0_DblClick(Cancel As Integer)
' text0 has input mask of !\(999") "000\-0000;;_"
' The user can copy "123 456.7890 extension 1-2345"
' from an email to clipboard
' then DoubleClick on textbox. All 15 digits will be
' pasted and will appear in the text box. The user can then cut the last digits
' and paste them into the extension text box.
' dataobject requires reference to Microsoft Forms 2.0 Object Library
' OPTIONALLY, dim y as regexp requires Microsoft VBScript Regular Expressions 5.5
Dim x As New dataobject
' Dim y As RegExp
Dim y As Object
Set y = CreateObject("vbscript.regexp")
y.Pattern = "[^\d]*"
y.Global = True
digits = y.Replace(x.GetText, "")
If Len(digits) = 7 Then digits = "000" & digits
Text0.Value = digits