Imbedded line feed in text field

B

brm3

I have hundreds of power point slides I need to clean up, and I am using VBA
(powerpoint 2003). One condition is causing me some problems. I have an if
statement and I am comparing to a text string in a field. Something like
this: If oTbl.Cell(I, 1).Shape.TextFrame.TextRange.Text = SearchString Then
delete. Some fields have more than one word in the test string. If the
author entered the text in the field and let it wrap, I am able to find it
using the code above. However, some authors would type in one word then hit
return and type in another word. So when I search on the string in the
field, I never find it. For example, if I entered Bob White the search
works. If I entered Bob (then put enter here) White. It will not find Bob
White when I use it as the SearchString. How do you find text with an
imbedded line return in the middle of it? Thank you.
 
J

John Wilson

Hi

The simple answer is change your code to look for "Bob" & vbCr & "White"
when you enter "Bob White" into (I guess) an InputBox.

Our programmers have a sign at their desks though, it says:
"I know you made it FOOLPROOF but you didn't factor in the ingenuity of
fools!"

Trust me some people will use soft returns (shirt/enter), tabs, multiple
spaces and ideas I can't even imagine to get the text onto two lines! This
code should find most combinations of one / two word entries



Dim strsplit() As String
Dim strsearch As String
strsearch = InputBox("enter")
strsplit = split(strsearch, " ")
With ActiveWindow.Selection.ShapeRange(1).TextFrame.TextRange
'change line above to = your shape
If UBound(strsplit) = 1 Then
If .Text Like strsplit(0) & "*" _
And .Text Like "*" & strsplit(1) Then MsgBox "Found Me"
Else
If .Text = strsplit(0) Then MsgBox "Found Me"
End If
End With




--
-------------------------------------------
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top