Copying text from regular textbox
I'm not positive exactly what you mean by copying the user's text - or
what you're trying to achieve overall - hopefully this will put you in
the right direction. In general, copying is rarely necessary when trying
to place text into a cell you can write directly.
Two ways of getting text from a textbox:
(1) Link it, so whatever is typed in the Textbox automatically appears
in the cell.
- Activate the Control Toolbox toolbar
- Switch into Design Mode
- Click your shape and then Properties on the toolbar.
- Set the LinkedCell property to E21
- Toggle out of design mode.
Now whatever is types into the Textbox will appear in E21.
(2) Alternatively, since you wanted to do this in VBA.
With ActiveSheet
.Range("E21") = .OLEObjects("TextBox1").Object.Text
End With
(Change TextBox1 name as appropriate.)
HTH,
Gareth
Greiffenberg wrote:
I'm trying in VBA to copy the text from a textbox.
When I try recording the macro of what I'm doing it uses the specific
text in the box, but since I want to copy the users text this will not
work:
ActiveSheet.Shapes("Text Box 3").Select
Selection.Characters.Text = "Text here"
With Selection.Characters(Start:=1, Length:=10).Font
Name = "Verdana"
FontStyle = "Regular"
Size = 10
Strikethrough = False
Superscript = False
Subscript = False
OutlineFont = False
Shadow = False
Underline = xlUnderlineStyleNone
ColorIndex = xlAutomatic
End With
Selection.Copy
Range("E21").Select
ActiveSheet.Paste
any help?
Greiffenberg
|