Link to home
Start Free TrialLog in
Avatar of Jimeo Williams
Jimeo WilliamsFlag for Thailand

asked on

find ^p^? but not ^p^p

I have a doc (Form.csv) I start in excel, copy and paste some data, close excel and open Form.csv in word. I run my macro and when it finishes I have my data in lines separated by ^p^p.
A few instances in my macro the find and replace doesn't work properly, so I am left with some lines of data that have ^p left in.
After the macro has finished I do a find: ^p^? which is all well and good, but means I have to search every line. I want to find ^p^? but not ^p^p
Avatar of Rgonzo1971
Rgonzo1971

HI,

maybe you should first replace
^p^p^p and then ^p^p to eliminate uneven and even numbers of paragraphs

Regards
Avatar of Jimeo Williams

ASKER

There are no ^p^p^p
Only ^p^p
and some paragraphs with ^p    this is the one I need to find and do a fix around it
I want to find ^p^? but not ^p^p
SOLUTION
Avatar of CompProbSolv
CompProbSolv
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you have a text editor, such as Notepad++, that will show you the text and non-text characters?  I'm curious about what is in the original CSV and what Excel does to the CSV content when it saves it.  I've seen cases where systems, such as UNIX/Linux, use Cr to delimit lines and Windows systems use/expect CrLf delimited lines.
It may be more effective to look at the actual problem: "A few instances in my macro the find and replace doesn't work properly, so I am left with some lines of data that have ^p left in."  What is your find-and-replace macro trying to do and why is it not working properly?
During the macro it can find the paragraph mark ^p but not replace it in some instances. Thanks for your help.
When I take out the double paragrah marks ^p^p and replace them with /// the document comes to a standstill. It's quicker to search through every paragraph mark.
When I put ^p^? in Find,  I can find all instances of double paragraphs and my errors, I just want to find the errors
Something like   ^p[!^p]^?   but that doesn't find anything
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks aikimark, I think I've fixed it.
I replaced all paragraph marks with a unique symbol at the start and replaced them at the finish of the macro.
So far, so good.
I didn't know about non-visible characters
"During the macro it can find the paragraph mark ^p but not replace it in some instances."  I would focus on this and not try to clean it up afterwards.  Why doesn't it replace it in some instances?
Sometimes the paragraph mark has a non-visible character next to it for some reason.
Changing ^p to another identifier at the start of the macro and inserting the ^p at the end seems to have fixed the problem.
Thanks for the help.