Hi Everyone,
I've tried a few things to try get this code to work without any manual intervention but I can't quite make it work. I found and adapted it from Greg Maxey's extremely helpful website. Would someone be kind enough to show me how to do this:
1/ The selection made from Listbox1 returns as text into my Word doc (this part works great - thanks Greg Maxey!!)
2/ Any text from the selection that contains text within between two ¦ signs would be bolded
3/ the ¦ would be removed from the selection
e.g. With selection range ¦This text here¦ would become ¦This text here¦ which would end up This text here
Therefore the bold identifiers ¦...¦ would be removed from the document altogether
I have thought about running code at the end of the "call UserForm" module but that would mean applying above requirements to the whole document and I really would prefer to steer away from doing that if possible.
Hopefully this is quite an easy thing for someone to help me with please? Or if you can point me in the right direction that would be a great help!
HTML Code:
Private Sub CommandButton1_Click()
Dim i As Long
Dim STYLE As String
Dim oRng As Word.Range
STYLE = ""
For i = 1 To ListBox1.ColumnCount
Select Case True
'Build the combo display
Case i = ListBox1.ColumnCount - 1
STYLE = STYLE & ListBox1.Column(i - 1) & " "
Case i = ListBox1.ColumnCount
STYLE = vbTab & ListBox1.Column(1) & vbCr & vbTab & _
ListBox1.Column(2) & vbCr & vbTab & _
ListBox1.Column(3) & vbCr & vbTab & _
ListBox1.Column(4) & vbCr & vbTab & _
ListBox1.Column(5) & vbCr & vbTab & _
ListBox1.Column(6) & vbCr & vbTab & _
ListBox1.Column(7) & vbCr & vbTab & _
ListBox1.Column(8) & vbCr & vbTab & _
ListBox1.Column(9) & vbCr & vbTab & _
ListBox1.Column(10) & vbCr & vbTab & _
ListBox1.Column(11) & vbCr & vbTab & _
ListBox1.Column(12) & vbCr & vbTab
Case Else
STYLE = STYLE & ListBox1.Column(i - 1) & vbCr '& vbTab
End Select
Next i
Set oRng = Selection.Range
oRng.Text = STYLE
'I believe it is around here that my range would be coded to identify words within ¦ identifiers
Me.Hide
lbl_Exit:
Exit Sub
End Sub
Many thanks!
Paul, Ireland