dj44
10-09-2017, 02:59 PM
folks good day
:)
I have got stuck on my select case.
Well i know there are other ways of doing what im trying to do with arrays and other stuff.
But i always get stuck on using select case although its meant to be easier
I wanted to keep my select case statements above in a block
Then I have my main code
So it helps me to keep things separate.
well i set it up but well it doesnt seem to be happening
this is a basic example.
Sub Select_Case()
For Each oPara In ActiveDocument.Paragraphs
Set oRng = oPara.Range
oFindText = oPara.Range.Text
'-------- All My Select Cases
Select Case oFindText
Case "@@@"
oInsertBefore = "Hello"
Case "***"
oInsertBefore = "Apple"
Case "###"
oInsertBefore = "Pear"
End Select
'-----------------------------
'-------- Main Code Block
If InStr(1, oRng.Text, oFindText) > 0 Then
oRng.Characters.First.InsertBefore oInsertBefore
End If
Next oPara
End Sub
I m not good at writing functions, and i was trying to avoid arrays
my Select case should work but im not sure why my idea doesnt work - it doesnt minus some syntaxtical error i suppose.
:)
I have got stuck on my select case.
Well i know there are other ways of doing what im trying to do with arrays and other stuff.
But i always get stuck on using select case although its meant to be easier
I wanted to keep my select case statements above in a block
Then I have my main code
So it helps me to keep things separate.
well i set it up but well it doesnt seem to be happening
this is a basic example.
Sub Select_Case()
For Each oPara In ActiveDocument.Paragraphs
Set oRng = oPara.Range
oFindText = oPara.Range.Text
'-------- All My Select Cases
Select Case oFindText
Case "@@@"
oInsertBefore = "Hello"
Case "***"
oInsertBefore = "Apple"
Case "###"
oInsertBefore = "Pear"
End Select
'-----------------------------
'-------- Main Code Block
If InStr(1, oRng.Text, oFindText) > 0 Then
oRng.Characters.First.InsertBefore oInsertBefore
End If
Next oPara
End Sub
I m not good at writing functions, and i was trying to avoid arrays
my Select case should work but im not sure why my idea doesnt work - it doesnt minus some syntaxtical error i suppose.