Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Textbox and Bullets

I was wondering if it is possible in a Userform textbox with Multi-Line to
automaticaly inser " * " on every line of just to inser that where ever
the user clicked within the textbox and ran the specific macro.


Ben Z.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Textbox and Bullets

On Apr 16, 4:54 pm, Benz wrote:
I was wondering if it is possible in a Userform textbox with Multi-Line to
automaticaly inser " * " on every line of just to inser that where ever
the user clicked within the textbox and ran the specific macro.

Ben Z.


Assuming you have a form with TextBox1 as the text box, this event-
handler code will add the bullet when you press Shift-Enter, Ctrl-
Enter or Ctrl-Shift-Enter (which is what you have to do in Excel 2003
to get a new line in a text box, as far as can tell). It will only add
a bullet to the last line if you hold enter to put multiple new lines.
You can change the bullet const string to whatever bullet you want.

Option Explicit

Private Const bullet As String = "* "

Private Sub TextBox1_Enter()
With TextBox1
If .Text = Empty Then
.Text = bullet
End If
End With
End Sub

Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
If KeyCode = vbKeyReturn And Shift 0 And Shift < 4 Then
With TextBox1
Dim sel_idx As Integer
sel_idx = .SelStart
.Text = Left(.Text, .SelStart + .CurLine) & bullet &
Right(.Text, Len(.Text) - .SelStart - .CurLine)
.SelStart = sel_idx + Len(bullet)
End With
End If
End Sub


Enjoy,
David G

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Textbox and Bullets

This works great!! Thank you David.

"David G" wrote:

On Apr 16, 4:54 pm, Benz wrote:
I was wondering if it is possible in a Userform textbox with Multi-Line to
automaticaly inser " * " on every line of just to inser that where ever
the user clicked within the textbox and ran the specific macro.

Ben Z.


Assuming you have a form with TextBox1 as the text box, this event-
handler code will add the bullet when you press Shift-Enter, Ctrl-
Enter or Ctrl-Shift-Enter (which is what you have to do in Excel 2003
to get a new line in a text box, as far as can tell). It will only add
a bullet to the last line if you hold enter to put multiple new lines.
You can change the bullet const string to whatever bullet you want.

Option Explicit

Private Const bullet As String = "* "

Private Sub TextBox1_Enter()
With TextBox1
If .Text = Empty Then
.Text = bullet
End If
End With
End Sub

Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
If KeyCode = vbKeyReturn And Shift 0 And Shift < 4 Then
With TextBox1
Dim sel_idx As Integer
sel_idx = .SelStart
.Text = Left(.Text, .SelStart + .CurLine) & bullet &
Right(.Text, Len(.Text) - .SelStart - .CurLine)
.SelStart = sel_idx + Len(bullet)
End With
End If
End Sub


Enjoy,
David G


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bullets and numbers OnWire Excel Discussion (Misc queries) 2 February 22nd 07 06:13 PM
Bullets in Excel mike_vr Excel Discussion (Misc queries) 7 February 13th 07 04:56 PM
Bullets & tabbing DaveL Excel Discussion (Misc queries) 3 September 26th 05 05:05 AM
Bullets kumawat_s Excel Discussion (Misc queries) 1 June 21st 05 01:45 PM
bullets Kari[_2_] Excel Programming 1 April 28th 04 11:59 PM


All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"