jsabo
08-18-2014, 04:46 AM
Hello,
Trying to user-input-error-proof a new macro w/ UI that I'm building in Word. As far as I can tell, I am unable to use an input mask... So i have the default value of the field as "DD-MMM-YYYY" to clearly hint for the user. But, I would still like to have validation that passes/fails if the user inputs correctly/incorrectly.
Here's what I'm trying so far, just to test in a separate file:
Dim oDate As Date
oDate = DateBox.Value
If Not oDate Like "##[-]???[-]####" Then
MsgBox "Please enter all dates in the following format: DD-MMM-YYYY"
Exit Sub
Else
MsgBox oDate
End If
Not really my first preferred go-to, but I think it could be sufficient. This in theory would validate that a date is entered like "05-Mar-2014". Any other suggestions or am I close to makine this work? Cheers.
Trying to user-input-error-proof a new macro w/ UI that I'm building in Word. As far as I can tell, I am unable to use an input mask... So i have the default value of the field as "DD-MMM-YYYY" to clearly hint for the user. But, I would still like to have validation that passes/fails if the user inputs correctly/incorrectly.
Here's what I'm trying so far, just to test in a separate file:
Dim oDate As Date
oDate = DateBox.Value
If Not oDate Like "##[-]???[-]####" Then
MsgBox "Please enter all dates in the following format: DD-MMM-YYYY"
Exit Sub
Else
MsgBox oDate
End If
Not really my first preferred go-to, but I think it could be sufficient. This in theory would validate that a date is entered like "05-Mar-2014". Any other suggestions or am I close to makine this work? Cheers.