Scrolling TextBox...?

  • Thread starter Thread starter Robert Stober
  • Start date Start date
Hi Robert

The controls toolbox has a textbox for use in spreadsheets and userforms.
Set its Multiline to true, Wordwrap to true and Scrollbars to whichever
desired.
 
Watch for linewrap. Adds a TextBox with scrolling capability.

Sub FileIntoTextBox()
'' Adds a text box which has a scroll bar.

Dim txtBox As MSForms.TextBox
Dim oleTB As OLEObject
Dim wSht As Worksheet
Dim wBk As Workbook

Application.ScreenUpdating = False

[a1].Select

Set wBk = ActiveWorkbook
Set wSht = wBk.ActiveSheet

Set oleTB = wSht.OLEObjects.Add(ClassType:="Forms.TextBox.1",
link:=False, _
DisplayAsIcon:=False, Left:=1, Top:=1, Width:=600,
Height:=150)
With oleTB
.Visible = True
.Name = "MyTextBox"
End With
Set txtBox = oleTB.Object

With txtBox
.Top = ActiveWindow.VisibleRange.Top + 100
.Left = ActiveWindow.VisibleRange.Left + 100
.MultiLine = True
.ScrollBars = 2
.EnterKeyBehavior = True
.Font.Name = "Courier New"
.Font.Size = 8
.SelStart = 1
End With

End Sub

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
 
Back
Top