VBA/Excel/Access/Word/Forms/TextBox
Содержание
Add TextBox and format it
Sub AddTextBox()
ActiveSheet.Shapes.AddTextBox(msoTextOrientationHorizontal, 2.5, 1.5, _
116, 145).TextFrame.Characters.text = "This is a test of inserting a text box to a sheet and adding some text."
With Selection.Characters(Start:=1, Length:=216).font
.name = "Arial"
.FontStyle = "Regular"
.size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
range("I15").Select
End Sub
Copy workbook differences to the worksheet
Private Sub cmdCopy_Click()
Workbooks("Compare WorkBooks.xls").Worksheets("Sheet1").Activate
Cells.Clear
Range("A1").Select
yourTextField.SelStart = 0
yourTextField.SelLength = Len(txtReferences.Text)
yourTextField.Copy
ActiveSheet.Paste
End Sub
Read input from TextBox and assign the value to ActiveCell
Private Sub OKButton_Click()
If CStr(SpinButton1.Value) = TextBox1.Text Then
ActiveCell = SpinButton1.Value
Unload Me
Else
MsgBox "Invalid entry.", vbCritical
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
End If
End Sub
Set the selection in a TextBox
Private Sub TextBox1_Enter()
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
End Sub