Pepito_child
New Member
- Joined
- Feb 13, 2016
- Messages
- 49
Hello all,
I have a workbook saved as Excel Macro-Enabled Template and sometimes when I open the file, after the userform is initialize, the rules for the textbox aren't available (the vba tab order and the limitation in writing only numbers).
If I press tab is adding space in the cell, also if I press any button from the keyboard is added to the cell.
Most of the times I don't have any problems when the userform appears to be edited, but if the userform is having problems, my solution is to double click in the worksheet, then on the userform and after that it's working like there are no problems.
Could there be a problem in my initialization code, does the userform interferes with other excel files and needs some restrictions?
I'm using two monitors and when the userform works perfectly is when it appears on the second screen, if it appears in the first monitor, there are also the errors.
Private Sub Workbook_Open()
UserForm1.Show
End Sub
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(".")
If InStr(1, Me.TextBox1.Text, ".") > 0 Then
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
End Sub
This are the settings for the text box object:
TabIndex - 1
TabKeyBehavior - False
TabStop - True
WordWrap - False
It's very frustrating because it's look like if I'm lucky, I can open the workbook with no errors.
Is there something that can be done for this userform to work fine?
Kind regards,
Pepito
I have a workbook saved as Excel Macro-Enabled Template and sometimes when I open the file, after the userform is initialize, the rules for the textbox aren't available (the vba tab order and the limitation in writing only numbers).
If I press tab is adding space in the cell, also if I press any button from the keyboard is added to the cell.
Most of the times I don't have any problems when the userform appears to be edited, but if the userform is having problems, my solution is to double click in the worksheet, then on the userform and after that it's working like there are no problems.
Could there be a problem in my initialization code, does the userform interferes with other excel files and needs some restrictions?
I'm using two monitors and when the userform works perfectly is when it appears on the second screen, if it appears in the first monitor, there are also the errors.
Private Sub Workbook_Open()
UserForm1.Show
End Sub
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(".")
If InStr(1, Me.TextBox1.Text, ".") > 0 Then
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
End Sub
This are the settings for the text box object:
TabIndex - 1
TabKeyBehavior - False
TabStop - True
WordWrap - False
It's very frustrating because it's look like if I'm lucky, I can open the workbook with no errors.
Is there something that can be done for this userform to work fine?
Kind regards,
Pepito